/* 货款发票管理系统 - 样式(对标批量转账系统 SaaS 风格) */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --blue: #2f6bff;
  --blue-dark: #1f54d8;
  --blue-bg: #eef3ff;
  --bg: #f2f4f9;
  --card: #ffffff;
  --line: #e7ebf3;
  --text: #1e2430;
  --text2: #4a5468;
  --muted: #8a93a6;
  --red: #f5483b;
  --red-bg: #fff1f0;
  --green: #16a34a;
  --green-bg: #ecfdf3;
  --orange: #f59e0b;
  --orange-bg: #fff8eb;
  --gray-bg: #f1f3f8;
  --shadow: 0 1px 4px rgba(23, 43, 99, .06);
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { display: block; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 216px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.logo-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--blue); color: #fff;
  font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-title { font-size: 15px; font-weight: 700; }
.logo-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 2px 10px;
  border-radius: 8px; color: var(--text2); font-size: 14px; cursor: pointer; user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--gray-bg); }
.nav-item.active { background: var(--blue-bg); color: var(--blue); font-weight: 600; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); line-height: 1.6; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; flex-shrink: 0;
}
.crumb { font-size: 14px; color: var(--text2); }
.crumb b { color: var(--text); font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text2); }
.user-chip { display: flex; align-items: center; gap: 6px; color: var(--text2); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.logout-link { color: var(--muted); }
.logout-link:hover { color: var(--red); }
.content { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }

/* ---------- 卡片与统计 ---------- */
.card { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 18px 20px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.c-blue { color: var(--blue); } .c-green { color: var(--green); } .c-red { color: var(--red); } .c-orange { color: var(--orange); } .c-gray { color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: transparent;
}
.table td { padding: 11px 12px; border-bottom: 1px solid #f0f2f8; font-size: 13px; vertical-align: middle; }
.table tbody tr:hover td { background: #f7f9fd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 徽章 ---------- */
.tag, .pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.tag.blue, .p-blue { background: var(--blue-bg); color: var(--blue); }
.tag.green, .p-green { background: var(--green-bg); color: var(--green); }
.tag.red, .p-red { background: var(--red-bg); color: var(--red); }
.tag.orange, .p-warn { background: var(--orange-bg); color: var(--orange); }
.tag.gray, .p-gray { background: var(--gray-bg); color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text2); transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: var(--red-bg); }
.btn.small, .btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.mini { padding: 2px 8px; font-size: 12px; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.input, .select, .textarea,
.form-row input, .form-row select, .form-row textarea,
.filter-bar select, .filter-bar input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; color: var(--text); background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus,
.form-row input:focus, .form-row select:focus, .form-row textarea:focus,
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }
.form-row { margin-bottom: 14px; }
.form-row label, .form-label { font-size: 13px; color: var(--text2); margin-bottom: 6px; display: block; }
.form-row label .req, .form-label .req { color: var(--red); }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-line { display: flex !important; align-items: center; gap: 8px; padding: 6px 0; }
.check-line input { width: auto !important; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.perm-grid label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text2); }

/* ---------- 登录 ---------- */
.login-wrap { height: 100dvh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef3ff 0%, #f7f9ff 60%, #f2f4f9 100%); padding: 16px; }
.login-card { width: 380px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 8px 40px rgba(23, 43, 99, .12); padding: 38px 36px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-err { color: var(--red); font-size: 13px; min-height: 20px; margin-bottom: 6px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.8; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 94vw; max-height: 88dvh; display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(15, 23, 42, .25); }
.modal.wide { width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal-close { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px; border: none; background: none; }
.modal-close:hover { background: var(--gray-bg); color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 400;
  padding: 10px 20px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 16px rgba(15, 23, 42, .15);
  background: var(--green-bg); color: var(--green); border: 1px solid #b7eb8f; display: none; max-width: 90vw;
  animation: toastIn .2s ease;
}
#toast.err { background: var(--red-bg); color: var(--red); border-color: #ffa39e; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 筛选条/合计条 ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar select, .filter-bar input { width: auto; }
.filter-bar .spacer { flex: 1; }
.totals-bar {
  display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px;
  background: var(--blue-bg); border-radius: 10px; font-size: 13px; color: var(--text2);
}
.totals-bar b { font-variant-numeric: tabular-nums; }

/* ---------- 台账付款卡 ---------- */
.pay-card { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.pay-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 18px; background: #f7f9fd; border-bottom: 1px solid var(--line);
}
.pay-period { font-weight: 700; font-size: 15px; }
.pay-sup { color: var(--blue); font-weight: 600; }
.pay-date { color: var(--muted); font-size: 13px; }
.pay-amounts { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pa-item { text-align: right; }
.pa-label { font-size: 11px; color: var(--muted); }
.pa-val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.pay-ops { display: flex; gap: 6px; }
.pay-body { padding: 12px 18px; }
.pay-note { color: var(--muted); font-size: 13px; }
.inv-rows { margin-top: 4px; }
.inv-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: 8px;
  background: #fbfcfe; font-size: 13px;
}
.inv-row .ir-date { color: var(--text2); }
.inv-row .ir-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.inv-row .ir-no { color: var(--muted); font-size: 12px; }
.inv-row .ir-ops { margin-left: auto; display: flex; gap: 6px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { width: 56px; height: 56px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; cursor: zoom-in; background: var(--gray-bg); }
.thumbs.small { margin: 0; }
.thumbs.small .thumb { width: 40px; height: 40px; }
.empty-tip { color: var(--muted); text-align: center; padding: 30px 0; font-size: 13px; }

/* ---------- 台账货款单卡片(v2: 一单一个单元, 左付款右发票) ---------- */
.order-card { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.order-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 18px; background: #f7f9fd; border-bottom: 1px solid var(--line);
}
.order-head .pay-ops { margin-left: auto; }
.order-total { font-size: 13px; color: var(--text2); }
.order-total b { font-size: 16px; font-variant-numeric: tabular-nums; color: var(--text); }
.order-cols { display: grid; grid-template-columns: 1fr 1fr; }
.ocol { padding: 12px 16px 14px; min-width: 0; }
.ocol.pay-col { border-right: 1px dashed var(--line); }
.ocol-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ocol-title { font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; color: var(--text2); }
.odot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.odot.blue { background: var(--blue); }
.odot.green { background: var(--green); }
.ocol-sum { font-size: 12px; color: var(--muted); }
.ocol-sum b { font-variant-numeric: tabular-nums; font-size: 14px; }
.ocol-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px;
}
.order-foot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 18px; background: #fbfcfe; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text2);
}
.order-foot b { font-variant-numeric: tabular-nums; }

/* ---------- 税点记录行 ---------- */
.tax-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 12px; border: 1px dashed #f3d9ae; border-radius: 8px;
  margin: -3px 0 8px 20px; background: #fffdf6; font-size: 12px;
}
.tax-row .ir-date { color: var(--text2); }
.tax-row .ir-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.tax-row .ir-ops { margin-left: auto; display: flex; gap: 6px; }

/* ---------- 期间月份选择器 ---------- */
.per-picker { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.per-months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; flex: 1; min-width: 250px; }
.per-m {
  padding: 7px 0; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 13px; color: var(--text2); cursor: pointer; transition: all .12s;
}
.per-m:hover { border-color: var(--blue); color: var(--blue); }
.per-m.on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.per-preview { margin-top: 8px; font-size: 12px; color: var(--text2); }
.per-preview b { color: var(--blue); font-size: 13px; }

/* ---------- 上传 ---------- */
.up-box { border: 1px dashed #c7d4ee; border-radius: 8px; padding: 12px; background: #fbfcfe; }
.up-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.up-item { position: relative; width: 64px; height: 64px; }
.up-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.up-item .up-del {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); color: #fff; border: none; font-size: 11px; line-height: 1;
}
.up-add {
  width: 64px; height: 64px; border: 1px dashed #c7d4ee; border-radius: 8px; background: #fff;
  color: var(--blue); font-size: 24px; display: flex; align-items: center; justify-content: center;
}
.up-tip { color: var(--muted); font-size: 12px; }

/* ---------- 看大图 ---------- */
.img-viewer { position: fixed; inset: 0; background: rgba(8, 14, 30, .92); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.img-viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.iv-close { position: absolute; top: 16px; right: 22px; color: #fff; font-size: 28px; cursor: pointer; }

/* ---------- 供应商卡 ---------- */
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.sup-card { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 16px 18px; cursor: pointer; transition: all .15s; }
.sup-card:hover { box-shadow: 0 6px 18px rgba(47, 107, 255, .14); transform: translateY(-1px); }
.sup-name { font-weight: 700; font-size: 15px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sup-nums { display: flex; justify-content: space-between; gap: 8px; }
.sup-nums .sn { flex: 1; }
.sn-l { font-size: 11px; color: var(--muted); }
.sn-v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.sup-foot { margin-top: 10px; color: var(--muted); font-size: 12px; }

/* ---------- 动态列表 ---------- */
.ev-list .ev-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #f0f2f8; }
.ev-list .ev-item:last-child { border-bottom: none; }
.ev-ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.ev-ico.pay { background: var(--blue-bg); color: var(--blue); }
.ev-ico.inv { background: var(--green-bg); color: var(--green); }
.ev-ico.fee { background: var(--orange-bg); color: var(--orange); }
.ev-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ev-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.ev-date { color: var(--muted); font-size: 12px; }

/* ---------- 底部标签栏(手机) ---------- */
.tabbar { display: none; }

/* ---------- 权限控制 ---------- */
body.no-edit .btn-add, body.no-edit .btn-edit { display: none !important; }
body.no-del .btn-del { display: none !important; }

/* ---------- 手机端 ---------- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 12px 12px calc(76px + env(safe-area-inset-bottom)); }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }
  .topbar { padding: 0 14px; }
  .crumb-prefix { display: none; }
  .user-chip #top-user { display: none; }
  .form-row input, .form-row select, .form-row textarea, .input, .select, .textarea { font-size: 16px; }
  .form-2col { grid-template-columns: 1fr; }
  .pay-head { gap: 8px; }
  .pay-amounts { margin-left: 0; width: 100%; justify-content: flex-start; gap: 12px; }
  .order-cols { grid-template-columns: 1fr; }
  .ocol.pay-col { border-right: none; border-bottom: 1px dashed var(--line); }
  .order-head .pay-ops { margin-left: 0; }
  .per-months { grid-template-columns: repeat(4, 1fr); }
  .tax-row { margin-left: 0; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    background: #fff; border-top: 1px solid var(--line);
    height: calc(54px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--muted); font-size: 10px; cursor: pointer;
  }
  .tab-item svg { width: 21px; height: 21px; }
  .tab-item.active { color: var(--blue); }
}
