:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --green: #059669;
  --green-bg: #ecfdf5;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, .10), 0 2px 8px rgba(17, 24, 39, .06);
}

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

[v-cloak] { display: none; }

html, body {
  height: 100%;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #eff6ff 0%, #f4f6fa 45%, #eef2f7 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(229, 231, 235, .8);
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.login-logo svg { width: 28px; height: 28px; }

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.3px;
  margin-bottom: 6px;
}

.login-card .sub {
  color: var(--text-3);
  font-size: 13px;
  margin-bottom: 26px;
}

/* ---------------- 布局 ---------------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 58px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.2px;
  margin-right: 12px;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.brand-mark svg { width: 16px; height: 16px; }

.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }

.nav button {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px;
  white-space: nowrap;
  transition: .15s;
}

.nav button:hover { background: #f3f4f6; color: var(--text); }
.nav button.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 500; }

.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); white-space: nowrap; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

.main { flex: 1; padding: 22px 20px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 18px 20px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-head h2 { font-size: 19px; font-weight: 600; letter-spacing: -.3px; }
.page-head .desc { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ---------------- 统计卡 ---------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.stat .label { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 650; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.stat.accent .value { color: var(--primary-dark); }
.stat.pending .value { color: var(--amber); }
.stat.done .value { color: var(--green); }

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.toolbar .spacer { flex: 1; }

.field { position: relative; display: flex; align-items: center; }

.input, .select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: .15s;
  font-size: 13.5px;
}

.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.input::placeholder { color: var(--text-3); }

.search-input { width: 220px; padding-left: 34px; }

.search-ico {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none;
}

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { background: #f9fafb; border-color: var(--border-2); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .3);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f3f4f6; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-danger { color: var(--red); border-color: #fecaca; background: var(--red-bg); }
.btn-danger:hover { background: #fee2e2; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12.5px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fbfcfd;
}

.tbl td {
  padding: 12px;
  border-bottom: 1px solid #f1f3f6;
  vertical-align: middle;
}

.tbl tbody tr:hover { background: #fafbfd; }
.tbl tbody tr.selected { background: var(--primary-light); }
.tbl tbody tr:last-child td { border-bottom: 0; }

.col-check { width: 40px; }
.col-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.col-actions { text-align: right; white-space: nowrap; }

.tbl input[type=checkbox] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}

.cell-main { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.cell-stack { min-width: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag-pending { background: var(--amber-bg); color: var(--amber); }
.tag-done { background: var(--green-bg); color: var(--green); }
.tag-skip { background: #f3f4f6; color: var(--text-3); }

.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  background: #f3f4f6;
  color: var(--text-2);
  white-space: nowrap;
}

.link-btn {
  border: 0; background: transparent; color: var(--primary); cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 5px;
}
.link-btn:hover { background: var(--primary-light); }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-3);
}
.empty svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: .5; }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-2);
  border-top: 1px solid var(--border);
}

.pager .pages { display: flex; gap: 6px; align-items: center; }

.page-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border-2); background: #fff;
  border-radius: 7px; cursor: pointer; font-size: 13px;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  backdrop-filter: blur(2px);
  animation: fade .18s ease;
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(17, 24, 39, .24);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.1);
}

@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }

.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: #fcfcfd;
  border-radius: 0 0 16px 16px;
}

.close-x {
  width: 30px; height: 30px; border-radius: 8px; border: 0;
  background: transparent; cursor: pointer; color: var(--text-3);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.close-x:hover { background: #f3f4f6; color: var(--text); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.form-item label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 5px;
  font-weight: 500;
}

.form-item .input, .form-item .select { width: 100%; }

textarea.input {
  height: auto; min-height: 64px; padding: 9px 12px; resize: vertical; line-height: 1.5;
}

/* 上传区 */
.dropzone {
  border: 1.5px dashed var(--border-2);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  transition: .15s;
  background: #fbfcfd;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}
.dropzone svg { width: 26px; height: 26px; margin-bottom: 6px; opacity: .7; }
.dropzone .hint { font-size: 12px; margin-top: 3px; opacity: .8; }

.file-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  background: #f8fafc; border: 1px solid var(--border);
  margin-top: 10px; font-size: 13px;
}
.file-chip .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 统计页 ---------------- */
.grid-2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }

.bar-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.bar-row .nm { width: 84px; font-size: 13px; color: var(--text-2); flex: none; }
.bar-track { flex: 1; height: 8px; background: #f1f3f6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2, .8, .3, 1); }
.bar-row .amt { width: 96px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 550; }

.month-chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 180px; padding: 8px 0 0;
}
.month-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.month-bar {
  width: 100%; max-width: 46px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  min-height: 3px; transition: height .5s cubic-bezier(.2, .8, .3, 1);
  position: relative;
}
.month-bar:hover { filter: brightness(1.08); }
.month-lbl { font-size: 11px; color: var(--text-3); white-space: nowrap; }

/* ---------------- 同步页 ---------------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-2); }
.form-row .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.55; }
.form-row .input, .form-row .select { width: 100%; max-width: 420px; }

.log-list { margin-top: 6px; }
.log-item {
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid #f1f3f6; font-size: 13px;
}
.log-item:last-child { border-bottom: 0; }
.log-item .t { color: var(--text-3); font-size: 12px; white-space: nowrap; width: 130px; flex: none; }
.log-item .m { color: var(--text-2); }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; z-index: 300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: toastIn .22s ease;
  max-width: 88vw;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px) } to { opacity: 1; transform: translate(-50%, 0) } }

.spin {
  width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: sp .7s linear infinite; display: inline-block;
}
@keyframes sp { to { transform: rotate(360deg) } }

.alert {
  padding: 11px 14px; border-radius: 9px; font-size: 13px;
  background: var(--amber-bg); color: #92400e;
  border: 1px solid #fde68a; margin-bottom: 16px; line-height: 1.6;
}
.alert-info { background: var(--primary-light); color: #1e40af; border-color: #bfdbfe; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
  .toolbar .field { flex: 1; }
}

@media (max-width: 720px) {
  .main { padding: 14px 12px 70px; }
  .topbar { padding: 0 12px; }
  .brand span { display: none; }
  .userbox .uname { display: none; }
  .stat-row { gap: 8px; }
  .stat { padding: 12px 13px; }
  .stat .value { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }

  /* 表格转卡片 */
  .table-wrap { overflow: visible; }
  table.tbl thead { display: none; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: 100%; }
  table.tbl tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 10px 12px;
    padding: 4px 0;
    background: #fff;
    position: relative;
  }
  table.tbl td {
    border: 0;
    padding: 6px 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  table.tbl td::before {
    content: attr(data-label);
    color: var(--text-3);
    font-size: 12.5px;
    flex: none;
  }
  table.tbl td[data-label="日期"] { padding-right: 46px; }
  table.tbl td[data-label="销售方"] .cell-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    min-width: 0;
  }
  table.tbl td[data-label="销售方"] .cell-main {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  table.tbl td.col-check { position: absolute; right: 10px; top: 12px; padding: 0; width: auto; }
  table.tbl td.col-check::before { display: none; }
  table.tbl td.col-amount { text-align: right; }
  table.tbl td.col-actions { justify-content: flex-end; padding-bottom: 10px; }
  table.tbl td.col-actions::before { display: none; }
  table.tbl tbody tr:hover { background: #fff; }
  .tbl tbody tr.selected { background: var(--primary-light); }
  .modal { max-height: 94vh; }
  .modal-body { padding: 16px; }
}
