/* ===========================================================
   发票整理助手 — 样式
   =========================================================== */

:root {
  --bg: #f3f5fa;
  --bg-soft: #eef1f7;
  --card: #ffffff;
  --card-alt: #fafbfe;
  --border: #e2e6ef;
  --border-strong: #cfd6e4;
  --text: #111a2e;
  --text-soft: #4c5875;
  --muted: #7b869c;
  --primary: #2563eb;
  --primary-soft: #e8efff;
  --primary-dark: #1d4ed8;
  --green: #0f9960;
  --green-soft: #e5f7ee;
  --amber: #b7791f;
  --amber-soft: #fdf3e0;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --purple: #7c3aed;
  --purple-soft: #efe9ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
  --sidebar-w: 306px;
}

[data-theme='dark'] {
  --bg: #0e1420;
  --bg-soft: #131c2b;
  --card: #161f2e;
  --card-alt: #1a2433;
  --border: #26313f;
  --border-strong: #354356;
  --text: #e8edf6;
  --text-soft: #aebbd0;
  --muted: #7f8da3;
  --primary: #5b8cff;
  --primary-soft: #1c2c4d;
  --primary-dark: #7ba3ff;
  --green: #3ddc97;
  --green-soft: #123527;
  --amber: #e2b04a;
  --amber-soft: #33280f;
  --red: #ff6b6b;
  --red-soft: #3a1717;
  --purple: #a78bfa;
  --purple-soft: #2a1f4d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

/* 让 hidden 属性优先于各处的 display 声明 */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ───────────── 顶栏 ───────────── */

.app-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: calc(var(--sidebar-w) - 40px);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.2px;
}

.brand-text small {
  color: var(--muted);
  font-size: 11.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

/* ───────────── 按钮 ───────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--muted);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--bg-soft);
}

.btn.small {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.btn.icon {
  width: 32px;
  padding: 0;
  justify-content: center;
  font-size: 15px;
}

.btn.small.icon {
  width: 26px;
}

.btn .ico {
  opacity: 0.85;
  font-size: 12px;
}

/* 下拉菜单 */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 60;
}

.dropdown.open .dropdown-menu {
  display: flex;
}

.dropdown-menu button {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-soft);
}

.dropdown-menu button:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.dropdown-menu button.danger {
  color: var(--red);
}

/* ───────────── 主体布局 ───────────── */

.app-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--card-alt);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-transform: uppercase;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.kpi {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.kpi.accent {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--primary-soft), var(--bg-soft));
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
}

.kpi-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi.accent .kpi-value {
  font-size: 22px;
  color: var(--primary);
}

.kpi-value.small {
  font-size: 14px;
}

.kpi-foot {
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.type-list,
.health-list,
.seller-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.type-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.type-name {
  flex: 1;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-count {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.type-sum {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 11.5px;
  min-width: 76px;
  text-align: right;
}

.bar-row {
  display: grid;
  grid-template-columns: 46px 1fr 62px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.bar-track {
  height: 7px;
  border-radius: 4px;
  background: var(--bg-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #22d3ee));
  transition: width 0.35s ease;
}

.bar-label {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.health-row b {
  font-variant-numeric: tabular-nums;
}

.health-row.warn b {
  color: var(--amber);
}

.health-row.bad b {
  color: var(--red);
}

.health-row.good b {
  color: var(--green);
}

.empty-hint {
  color: var(--muted);
  font-size: 12px;
  padding: 2px 0;
}

/* ───────────── 主区 ───────────── */

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  background: var(--card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  min-width: 250px;
  flex: 1 1 250px;
  max-width: 420px;
}

/* 「隐藏清单文件」开关 */
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.chip-check:hover {
  background: var(--bg-soft);
}

.chip-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.chip-check b {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 16px;
}

.chip-check.off {
  color: var(--muted);
}

.chip-check.off b {
  background: var(--bg-soft);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-box .ico {
  color: var(--muted);
  font-size: 14px;
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.toolbar-info {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.drop-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  white-space: nowrap;
}

.drop-hint .ico {
  color: var(--primary);
}

/* 启动失败遮罩 */
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 16, 28, 0.72);
  backdrop-filter: blur(4px);
}

.boot-error-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 22px 26px;
  max-width: 620px;
}

.boot-error-box h2 {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--red);
}

.boot-error-box p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-soft);
}

.boot-error-box code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  color: var(--primary);
}

.boot-error-box .boot-note {
  margin-bottom: 0;
  font-size: 12px;
  color: var(--muted);
}

/* ───────────── 表格 ───────────── */

.table-wrap {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  padding: 0 0 8px;
}

.invoice-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.8px;
  min-width: 1300px;
}

.invoice-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}

.invoice-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.invoice-table thead th.sortable:hover {
  color: var(--primary);
}

.invoice-table thead th.sorted-asc::after {
  content: ' ▲';
  font-size: 9px;
  color: var(--primary);
}

.invoice-table thead th.sorted-desc::after {
  content: ' ▼';
  font-size: 9px;
  color: var(--primary);
}

.invoice-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  background: var(--card);
  white-space: nowrap;
}

.invoice-table tbody tr:hover td {
  background: var(--bg-soft);
}

.invoice-table tbody tr.row-issues td {
  background: color-mix(in srgb, var(--amber-soft) 55%, var(--card));
}

.invoice-table tbody tr.row-issues:hover td {
  background: var(--amber-soft);
}

.invoice-table tbody tr.row-error td {
  background: color-mix(in srgb, var(--red-soft) 45%, var(--card));
}

.invoice-table tbody tr.selected td {
  background: var(--primary-soft);
}

/* 行程清单 / 票据汇总单：淡灰底 + 弱化文字，一眼看出不是发票 */
.invoice-table tbody tr.row-listing td {
  background: color-mix(in srgb, var(--muted) 7%, var(--card));
  color: var(--muted);
}

/* 支付截图：颜色偏紫一点，和行程清单区分开 */
.invoice-table tbody tr.row-payment td {
  background: color-mix(in srgb, var(--purple, #8b5cf6) 8%, var(--card));
  color: var(--muted);
}

.invoice-table tbody tr.row-payment:hover td {
  background: color-mix(in srgb, var(--purple, #8b5cf6) 14%, var(--card));
}

.invoice-table tbody tr.row-payment td.col-money {
  color: var(--muted);
  font-weight: 500;
}

.invoice-table tbody tr.row-listing:hover td {
  background: color-mix(in srgb, var(--muted) 13%, var(--card));
}

.invoice-table tbody tr.row-listing td.col-money {
  color: var(--muted);
  font-weight: 500;
}

.col-check {
  width: 34px;
}

.col-idx {
  width: 40px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-type {
  width: 112px;
}

.col-class {
  width: 96px;
}

.class-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-select {
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  padding: 0 8px;
  color: var(--text-soft);
  font-size: 12.5px;
  cursor: pointer;
  max-width: 150px;
}

.toolbar-select:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.col-no {
  width: 166px;
}

.col-date {
  width: 92px;
}

.col-company {
  width: 180px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-money {
  width: 90px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.col-source {
  width: 152px;
  max-width: 152px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 11.8px;
}

.col-actions {
  width: 94px;
  text-align: right;
}

.invoice-table td.col-money {
  font-weight: 600;
}

.invoice-table td.col-money.total {
  color: var(--primary);
}

.invoice-table td.col-no {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  letter-spacing: 0.2px;
}

.cell-empty {
  color: var(--muted);
}

.row-actions {
  display: inline-flex;
  gap: 4px;
  justify-content: flex-end;
}

.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--primary);
}

.icon-btn.danger:hover {
  color: var(--red);
  background: var(--red-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid transparent;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge.special {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: color-mix(in srgb, var(--purple) 25%, transparent);
}

.badge.normal {
  color: var(--green);
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 25%, transparent);
}

.badge.other {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 25%, transparent);
}

.badge.dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border-radius: 50%;
  flex: 0 0 auto;
}

.mini-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 4px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-soft);
  cursor: help;
  vertical-align: middle;
}

.mini-flag.bad {
  color: var(--red);
  background: var(--red-soft);
}

.mini-flag.info {
  color: var(--primary);
  background: var(--primary-soft);
}

.mini-flag.ocr {
  color: #fff;
  background: var(--amber);
  font-weight: 800;
  letter-spacing: 0.3px;
}

.mini-flag.ok {
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

/* 空状态 */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 32px;
  color: var(--text-soft);
  pointer-events: none;
}

.empty-state .empty-icon {
  font-size: 46px;
  filter: saturate(0.85);
}

.empty-state h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 13px;
}

.empty-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  pointer-events: auto;
}

.empty-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

/* 分页 */
.pager {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-soft);
}

.pager-left,
.pager-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager select {
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  padding: 0 4px;
}

.page-indicator {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 56px;
  text-align: center;
}

.selection-info {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* ───────────── 拖拽遮罩 ───────────── */

.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  place-items: center;
  z-index: 340; /* 高于弹窗，保证任何状态下拖入都有反馈 */
}

.drop-overlay.active {
  display: grid;
}

.drop-box {
  border: 2.5px dashed rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: 42px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: rgba(37, 99, 235, 0.22);
  text-align: center;
  max-width: min(560px, 90vw);
}

.drop-box strong {
  font-size: 20px;
}

.drop-box span {
  font-size: 13px;
  opacity: 0.85;
}

.drop-icon {
  font-size: 40px;
}

.drop-overlay.reading .drop-icon {
  animation: drop-pulse 1s ease-in-out infinite;
}

@keyframes drop-pulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(4px);
    opacity: 0.55;
  }
}

/* ───────────── 进度面板 ───────────── */

.progress-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 400px;
  max-width: calc(100vw - 36px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  z-index: 350; /* 高于弹窗：弹窗打开时拖入文件也能看到进度 */
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-head strong {
  font-size: 13px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  transition: width 0.2s ease;
}

.progress-fill.indeterminate {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% {
    margin-left: -35%;
  }
  100% {
    margin-left: 100%;
  }
}

.progress-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-log {
  max-height: 108px;
  overflow-y: auto;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.progress-log .warn {
  color: var(--amber);
}

.progress-log .error {
  color: var(--red);
}

/* ───────────── 弹窗 ───────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 28, 0.5);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-dialog.wide {
  width: min(1300px, 100%);
  height: calc(100vh - 48px);
}

.modal-dialog.medium {
  width: min(940px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card-alt);
  flex: 0 0 auto;
}

.modal-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.modal-title strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-title small {
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px;
}

.modal-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  background: var(--card-alt);
}

.modal-foot .hint {
  color: var(--muted);
  font-size: 12px;
}

.preview-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
  background: var(--bg-soft);
}

.preview-canvas-wrap {
  overflow: auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  min-height: 0;
}

.preview-canvas-wrap canvas {
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow);
  max-width: 100%;
}

.preview-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 0;
}

.preview-fields {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  font-size: 12.5px;
  align-items: baseline;
}

.field-row dt {
  color: var(--muted);
}

.field-row dd {
  margin: 0;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
}

.field-row dd.money {
  font-weight: 700;
  color: var(--primary);
}

.issue-list {
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--amber);
  font-size: 12px;
}

.raw-text {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
}

.raw-text summary {
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 600;
}

.raw-text pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow: auto;
  color: var(--text-soft);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
}

.edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  align-content: start;
}

/* ───────────── 编辑 / 核对弹窗 ───────────── */

.edit-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-issues {
  background: var(--amber-soft);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.edit-issues b {
  color: var(--amber);
}

.edit-issues ul {
  margin: 5px 0 0;
  padding-left: 18px;
}

.edit-issues li {
  margin: 2px 0;
}

.field-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}

.field-wrap input,
.field-wrap select {
  flex: 1 1 auto;
  min-width: 0;
}

.adopt-btn {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.adopt-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* 输入框里被改过的字段（与识别值不同）打上标记 */
.edit-form input.changed,
.edit-form select.changed {
  border-color: var(--amber);
  background: color-mix(in srgb, var(--amber-soft) 45%, var(--card));
}

.edit-verify {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}

.verify-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text-soft);
}

.verify-row .v-ico {
  flex: 0 0 auto;
  font-weight: 700;
}

.verify-row.ok .v-ico {
  color: var(--green);
}

.verify-row.warn .v-ico {
  color: var(--amber);
}

.verify-row.bad .v-ico {
  color: var(--red);
}

.verify-row.muted {
  color: var(--muted);
}

.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.edit-form label.span-2 {
  grid-column: 1 / -1;
}

.edit-form input,
.edit-form select {
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  padding: 0 10px;
  outline: 0;
  color: var(--text);
}

.edit-form input:focus,
.edit-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ───────────── 合并表单 ───────────── */

.merge-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  align-content: start;
}

.merge-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-soft);
}

.merge-form label.span-2,
.merge-form .span-2 {
  grid-column: 1 / -1;
}

.merge-form label.check {
  flex-direction: row;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 2px 0;
}

.merge-form label.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.merge-form input[type='text'],
.merge-form select {
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  padding: 0 10px;
  outline: 0;
  color: var(--text);
  width: 100%;
}

.merge-form input[type='text']:focus,
.merge-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.merge-note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.merge-note b {
  color: var(--text-soft);
}

.merge-note .warn {
  color: var(--amber);
}

/* ───────────── 发票号码统计 ───────────── */

.number-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.num-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.num-kpis .kpi {
  padding: 9px 11px;
}

.num-kpis .kpi-value {
  font-size: 19px;
}

.num-kpis .kpi.highlight {
  background: linear-gradient(135deg, var(--primary-soft), var(--bg-soft));
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}

.num-kpis .kpi.highlight .kpi-value {
  color: var(--primary);
}

.num-kpis .kpi.bad {
  background: var(--red-soft);
}

.num-kpis .kpi.bad .kpi-value {
  color: var(--red);
}

.num-section > h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.num-section > h4 .count {
  font-weight: 500;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.num-scroll {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.num-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.num-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-soft);
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}

.num-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.num-table tbody tr:last-child td {
  border-bottom: 0;
}

.num-table tbody tr:hover td {
  background: var(--bg-soft);
}

.num-table td.mono {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  letter-spacing: 0.2px;
}

.num-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.num-table td.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.num-table td.path {
  color: var(--muted);
  font-size: 11.5px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num-table .tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--red-soft);
  color: var(--red);
}

.num-table .tag.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.num-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.num-bars .bar-row {
  grid-template-columns: 104px 1fr 70px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
}

.inline-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.linkish {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.linkish:hover {
  color: var(--primary-dark);
}

.num-empty {
  color: var(--muted);
  font-size: 12.5px;
  padding: 10px 2px;
}

/* ───────────── 关键词分类规则编辑器 ───────────── */

.rules-body {
  padding: 12px 14px;
}

.rules-head,
.rules-row {
  display: grid;
  grid-template-columns: 34px 148px 1fr 48px 34px;
  gap: 8px;
  align-items: center;
}

.rules-head {
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 2px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow: auto;
  padding-right: 2px;
}

.rules-row input[type='text'] {
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  padding: 0 8px;
  font-size: 12.5px;
  color: var(--text);
  min-width: 0;
}

.rules-row input[type='text']:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.rules-row input.rule-color {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
}

.rules-row .rule-count {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.rules-tip {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.rules-tip b {
  color: var(--text-soft);
}

/* ───────────── 二维码核对结果 ───────────── */

.qr-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.qr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.qr-raw {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 6px 8px;
  word-break: break-all;
  max-height: 84px;
  overflow: auto;
}

.qr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.qr-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.qr-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
}

.qr-table td.mono {
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
}

.qr-table td small {
  color: var(--muted);
}

.qr-table tr.bad td {
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
}

.help-body h3 {
  margin: 14px 0 6px;
  font-size: 13.5px;
  color: var(--text);
}

.help-body h3:first-child {
  margin-top: 0;
}

.help-body p,
.help-body li {
  color: var(--text-soft);
  font-size: 13px;
  margin: 0 0 6px;
}

.help-body ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

/* ───────────── Toast ───────────── */

.toasts {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 400;
  pointer-events: none;
  max-width: 380px;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 9px 12px;
  font-size: 12.8px;
  color: var(--text-soft);
  animation: toast-in 0.22s ease;
  pointer-events: auto;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.toast.success {
  border-left-color: var(--green);
}

.toast.warn {
  border-left-color: var(--amber);
}

.toast.error {
  border-left-color: var(--red);
}

.toast .toast-icon {
  flex: 0 0 auto;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ───────────── 滚动条 ───────────── */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 65%, transparent);
  background-clip: content-box;
}

/* ───────────── 响应式 ───────────── */

@media (max-width: 1180px) {
  :root {
    --sidebar-w: 264px;
  }
  .preview-body {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
  .brand-text small {
    display: none;
  }
}

@media (max-width: 940px) {
  .sidebar {
    display: none;
  }
  .preview-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .brand {
    min-width: 0;
  }
  .app-foot .foot-note {
    display: none;
  }
}

@media (max-width: 560px) {
  .app-foot {
    flex-direction: column;
    gap: 2px;
    padding: 5px 10px;
  }
  .app-foot .foot-sep {
    display: none;
  }
}

/* ─────────────── 页脚（在线访问链接 / 联系邮箱） ─────────────── */
.app-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.app-foot .foot-sep {
  color: var(--border-strong);
}

.app-foot a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.app-foot a:hover {
  text-decoration: underline;
}

.app-foot a.link-site::before {
  content: '🔗';
  margin-right: 5px;
  font-weight: 400;
}

.app-foot a.link-mail::before {
  content: '✉';
  margin-right: 5px;
  font-weight: 400;
}

/* 版权行：独占一行，居中显示在页脚最底部 */
.app-foot .foot-copyright {
  flex: 0 0 auto;
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.01em;
}
