/* ========== 发票管家 ========== */
:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #eef2ff;
  --success: #059669;
  --success-light: #d1fae5;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --rose: #e11d48;
  --rose-light: #ffe4e6;
  --ink: #1e293b;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --bg: #f5f6fa;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .16);
}

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

html { -webkit-text-size-adjust: 100%; }

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

.container { max-width: 1440px; margin: 0 auto; padding: 18px 20px 60px; }

/* ---------- 顶栏 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-size: 22px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
.brand-text h1 { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand-text p { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.header-actions { display: flex; gap: 8px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 600;
  border: 1px solid transparent; border-radius: 10px;
  cursor: pointer; user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 3px 10px rgba(5, 150, 105, .28); }
.btn-success:hover { background: #047857; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); padding: 9px 12px; }
.btn-ghost:hover { background: #f8fafc; }
.btn-ghost.danger:hover { color: var(--rose); border-color: #fecdd3; background: var(--rose-light); }

/* ---------- 进度条 ---------- */
.progress {
  position: sticky; top: 67px; z-index: 49;
  padding: 10px 20px;
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.progress-info { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.progress-track { height: 6px; background: var(--brand-light); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .25s ease; }

/* ---------- 统计卡片 ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, .7);
}
.stat-label { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.stat-value { font-size: 21px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat-value.money { color: var(--success); }
.stat-value.amber { color: var(--amber); }
.stat-value.rose { color: var(--rose); }

/* ---------- 拖拽区 ---------- */
.dropzone {
  border: 2px dashed #c7d2fe; border-radius: var(--radius);
  background: var(--brand-light);
  text-align: center;
  padding: 30px 18px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: all .15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: #e0e7ff; }
.dz-icon { font-size: 30px; margin-bottom: 6px; }
.dz-main { font-size: 15px; font-weight: 600; color: var(--ink); }
.dz-hint { font-size: 12px; color: var(--ink-2); margin-top: 6px; line-height: 1.8; }
.dropzone.compact { padding: 12px; }
.dropzone.compact .dz-icon { display: none; }
.dropzone.compact .dz-main { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.dropzone.compact .dz-hint { display: none; }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px;
}
.search-icon { color: var(--ink-3); font-size: 13px; }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  padding: 9px 0; font-size: 14px; color: var(--ink);
  min-width: 0;
}
.filter-select {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 9px 10px; font-size: 13px; color: var(--ink-2); outline: none;
}
.toolbar-count { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty-icon { font-size: 46px; margin-bottom: 10px; }
.empty-state p { font-size: 15px; color: var(--ink-2); }
.empty-sub { font-size: 12px !important; margin-top: 6px; }

/* ---------- 电脑端表格 ---------- */
.table-wrap {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, .7);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1500px; }
thead th {
  position: sticky; top: 0;
  background: #f8fafc; color: var(--ink-2);
  font-size: 12px; font-weight: 600;
  text-align: left; white-space: nowrap;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brand); }
th.sortable .arrow { font-size: 10px; margin-left: 3px; }
tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  max-width: 220px;
  word-break: break-all;
}
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.editable { cursor: text; }
td.editable:hover { outline: 1px dashed #c7d2fe; outline-offset: -2px; }
td.editable:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fffbeb; }
.col-status { width: 64px; }
.col-items { min-width: 160px; }
.col-ops { width: 76px; }
.cell-src { font-size: 12px; color: var(--ink-3); max-width: 140px; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pill.ok { background: var(--success-light); color: var(--success); }
.pill.partial { background: var(--amber-light); color: var(--amber); }
.pill.failed { background: var(--rose-light); color: var(--rose); }

.row-ops { display: flex; gap: 4px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; padding: 4px 6px; border-radius: 8px; line-height: 1;
  transition: background .12s;
}
.icon-btn:hover { background: #e2e8f0; }
.icon-btn.del:hover { background: var(--rose-light); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- 手机端卡片 ---------- */
.cards { display: none; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, .7);
  padding: 14px;
  margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title .no { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 2px; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-size: 13px; color: var(--ink);
  outline: none; background: #fbfcfe;
  font-family: inherit;
}
.field input:focus { border-color: var(--brand); background: #fff; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.card-src { font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

/* ---------- 弹窗 / Toast ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.modal-body {
  position: relative; z-index: 1;
  width: min(920px, 94vw); height: min(88vh, 900px);
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  overflow: hidden; display: flex; flex-direction: column;
}
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(15,23,42,.6); color: #fff;
  font-size: 15px; cursor: pointer;
}
.modal-content { flex: 1; overflow: auto; display: grid; place-items: center; background: #334155; }
.modal-content iframe { width: 100%; height: 100%; border: none; background: #fff; }
.modal-content img { max-width: 100%; max-height: 100%; object-fit: contain; }

.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%);
  z-index: 200;
  background: #1e293b; color: #fff;
  padding: 11px 20px; border-radius: 12px;
  font-size: 13px; box-shadow: var(--shadow-lg);
  max-width: 88vw; text-align: center;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 页脚 ---------- */
.app-footer { margin-top: 26px; color: var(--ink-3); font-size: 12px; line-height: 2; }

.hidden { display: none !important; }

/* ========== 手机端适配 ========== */
@media (max-width: 860px) {
  .container { padding: 14px 12px 50px; }
  .app-header { padding: 10px 12px; flex-wrap: wrap; }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 16px; }
  .brand-icon { width: 36px; height: 36px; font-size: 19px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .btn .btn-text { display: none; }
  .btn .btn-icon { font-size: 16px; }
  .btn-primary::after { content: "导入"; margin-left: 2px; }
  .btn-success::after { content: "导出"; margin-left: 2px; }

  .progress { top: 57px; }

  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-value { font-size: 17px; }

  .dropzone { padding: 20px 12px; }
  .dz-hint br { display: none; }

  .toolbar { flex-wrap: wrap; }
  .toolbar-count { width: 100%; }

  .table-wrap { display: none; }
  .cards { display: block; }
  .empty-state { padding: 40px 16px; }
}
