/* ===== 基础重置 ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #1e293b;
  background: #f1f5f9;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

/* ===== 登录视图 ===== */
/* 全局：确保 hidden 属性始终生效（覆盖 display:flex/grid 等） */
[hidden] { display: none !important; }
.auth-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #7c3aed 100%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 40px; margin-bottom: 8px; }
.auth-header h1 { margin: 0; font-size: 22px; font-weight: 600; }
.auth-subtitle { margin: 4px 0 0; color: var(--gray-500); font-size: 12px; letter-spacing: 1px; }

.auth-tabs { display: flex; border-bottom: 1px solid var(--gray-200); margin-bottom: 20px; }
.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.auth-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 500;
}
.auth-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--gray-400); cursor: not-allowed; }

.btn-wechat {
  width: 100%;
  padding: 10px;
  background: #07c160;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
}
.btn-wechat:hover { background: #06ad56; }
.wx-icon { display: inline-block; padding: 2px 6px; background: #fff; color: #07c160; border-radius: 4px; font-size: 12px; font-weight: bold; margin-right: 4px; }

.auth-hint { margin-top: 10px; font-size: 12px; color: var(--gray-500); text-align: center; }
.form-error { margin-top: 10px; color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; }

.wechat-divider {
  display: flex;
  align-items: center;
  margin: 20px 0 14px;
  color: var(--gray-400);
  font-size: 12px;
}
.wechat-divider::before, .wechat-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.wechat-divider span { padding: 0 12px; }

.wechat-qr {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.wechat-qr img { width: 200px; height: 200px; display: block; }
.wechat-hint { margin-top: 8px; font-size: 12px; color: var(--gray-400); text-align: center; }

.auth-footer { margin-top: 24px; color: rgba(255, 255, 255, 0.7); font-size: 12px; }

/* ===== 主应用布局 ===== */
.main-view {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(135deg, #eef4ff 0%, #f5f9ff 100%);
  position: relative;
}
.sidebar-brand::after {
  content: '⌂';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--primary);
  opacity: 0.6;
  transition: opacity 0.15s;
}
.sidebar-brand:hover { background: linear-gradient(135deg, #e1ecff 0%, #eaf2ff 100%); }
.sidebar-brand:hover::after { opacity: 1; }
.brand-logo {
  font-size: 28px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(47, 107, 255, 0.25);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: 0.3px;
}
.brand-sub {
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.2;
}

/* 操作手册按钮特殊样式：作为外部链接，不高亮当前路由 */
.sidebar-nav a[href$=".docx"] { color: var(--primary); }
.sidebar-nav a[href$=".docx"]:hover { background: var(--gray-50); color: var(--primary-dark, #1d4fc7); }

/* ===== 产品明细表（合同录入 + 详情） ===== */
.lines-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-top: 8px;
  background: white;
}
.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1000px;
}
.lines-table thead th {
  background: var(--gray-50);
  color: var(--gray-700);
  font-weight: 600;
  padding: 10px 6px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  text-align: center;
}
.lines-table tbody td {
  padding: 6px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.lines-table tbody tr:hover { background: var(--gray-50); }
.lines-table tfoot td {
  padding: 12px 6px;
  border-top: 2px solid var(--gray-300);
  background: var(--gray-50);
  font-size: 14px;
}
.lines-table input,
.lines-table textarea {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  font-size: 13px;
  border-radius: 4px;
  font-family: inherit;
  resize: vertical;
}
.lines-table input:focus,
.lines-table textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 2px rgba(47, 107, 255, 0.1);
}
.lines-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.lines-table .col-seq { width: 36px; text-align: center; color: var(--gray-500); font-weight: 500; }
.lines-table .col-num { width: 88px; text-align: right; }
.lines-table .col-warranty { width: 56px; text-align: center; }
.lines-table .col-date { width: 130px; }
.lines-table .col-action { width: 44px; text-align: center; }
.lines-table .col-term-pct { width: 110px; }
.lines-table .col-term-amt { width: 130px; }

/* 详情模式下的表格：去掉编辑控件，只读 */
.lines-table.lines-table-detail input,
.lines-table.lines-table-detail textarea {
  border: none;
  background: transparent;
  padding: 0;
}
.lines-table.lines-table-detail tbody td {
  padding: 10px 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--gray-700);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: var(--gray-100); text-decoration: none; }
.sidebar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: 0.85; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--gray-200); }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--gray-50);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--gray-500); }

/* ===== 主内容区 ===== */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.btn-ghost {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  color: var(--gray-700);
  font-size: 13px;
}
.btn-ghost:hover { background: var(--gray-100); }

.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== 通用卡片与工具栏 ===== */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; color: var(--gray-800); display: flex; align-items: center; justify-content: space-between; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.search-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  min-width: 200px;
}
.search-input:focus { border-color: var(--primary); }

.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid var(--gray-300);
  background: #fff;
  color: var(--gray-700);
  transition: all 0.15s;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-primary-solid {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary-solid:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== KPI 卡片 ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--gray-200);
}
.kpi-label { color: var(--gray-500); font-size: 13px; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 600; color: var(--gray-900); }
.kpi-unit { font-size: 13px; color: var(--gray-500); margin-left: 4px; font-weight: normal; }
.kpi-card.alert-kpi { border-left: 3px solid var(--warning); }
.kpi-card.danger-kpi { border-left: 3px solid var(--danger); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 500;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
}

/* ===== 状态徽章 ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-700);
}
.badge.success { background: #d1fae5; color: #047857; }
.badge.warning { background: #fef3c7; color: #b45309; }
.badge.danger { background: #fee2e2; color: #b91c1c; }
.badge.info { background: var(--primary-light); color: var(--primary); }
.badge.gray { background: var(--gray-100); color: var(--gray-600); }

/* 合同类型徽章 */
.badge.badge-sales {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
.badge.badge-purchase {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}
.badge.type-tag-large {
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}

/* 发票状态徽章 */
.badge.badge-issued {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #6ee7b7;
}
.badge.badge-not-issued {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}
.badge.badge-received {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}
.badge.badge-not-received {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* 自动生成合同号按钮 */
.btn.btn-generate {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: white;
  border: none;
  font-size: 12px;
  padding: 6px 10px;
  white-space: nowrap;
}
.btn.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}
.form-hint {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* 只读 banner（顶部条） */
.readonly-banner {
  background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  padding: 8px 16px;
  font-size: 13px;
  border-left: 3px solid #f59e0b;
  margin-left: auto;
  margin-right: auto;
  border-radius: var(--radius);}

/* 我的数据视图 banner（非管理员） */
.scope-banner {
  background: linear-gradient(90deg, #eef2ff 0%, #e0e7ff 100%);
  color: #3730a3;
  padding: 8px 16px;
  font-size: 13px;
  border-left: 3px solid #6366f1;
  margin-left: auto;
  margin-right: auto;
  border-radius: var(--radius);
  margin-top: 4px;
}
.scope-banner strong { font-weight: 600; }

/* ===== 模态框 ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-large { max-width: 880px; }
.modal-xl { max-width: 1200px; }
/* 全屏模式：取消所有尺寸限制，紧贴视口四边 */
.modal-fullscreen {
  max-width: none !important;
  width: calc(100vw - 32px) !important;
  height: calc(100vh - 32px) !important;
  max-height: none !important;
  border-radius: var(--radius) !important;
}
.modal-fullscreen .modal-body { padding: 24px 28px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.modal-header-actions { display: flex; gap: 6px; align-items: center; }
.modal-icon-btn {
  background: none; border: 1px solid transparent;
  color: var(--gray-500); cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
  font-size: 18px; line-height: 1;
  transition: background 120ms, color 120ms;
}
.modal-icon-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--gray-400); cursor: pointer; padding: 0 6px; line-height: 1; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== 表单 ===== */
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 18px 0 10px;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
}
.form-section-title:first-child { margin-top: 0; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
/* 大窗：xl / 全屏模态里表单字段自动变 3 列展开 */
.modal-xl .form-grid,
.modal-fullscreen .form-grid {
  grid-template-columns: repeat(3, 1fr);
}
.modal-xl .form-grid .full,
.modal-fullscreen .form-grid .full { grid-column: 1 / -1; }
/* 更大窗（>=1600px）：4 列 */
@media (min-width: 1600px) {
  .modal-xl .form-grid,
  .modal-fullscreen .form-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  outline: none;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.form-field textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }

/* ===== Toast ===== */
#toast-root {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  background: var(--gray-800);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slide-in 0.2s ease-out;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Tabs ===== */
.tabs { display: flex; border-bottom: 1px solid var(--gray-200); margin-bottom: 20px; gap: 4px; }
.tabs .tab {
  padding: 10px 16px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ===== 进度条 ===== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }

/* ===== 详情页 ===== */
.detail-header {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 16px;
}
.detail-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.detail-title-row h2 { margin: 0; font-size: 20px; }
.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 20px;
  font-size: 13px;
}
.detail-meta-item .label { color: var(--gray-500); margin-bottom: 2px; font-size: 12px; }
.detail-meta-item .value { color: var(--gray-800); font-weight: 500; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .main-view { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

/* ===== v2.5：产品明细表格可拖拽调整大小 ===== */
/* 合同录入 modal 中的产品明细表：右下角出现拖拽手柄，可横向/纵向调整容器大小，
   表格在容器内横向/纵向滚动；modal-xl 与全屏模式均适用 */
.lines-resizable {
  resize: both;
  overflow: auto;
  min-width: 360px;
  min-height: 160px;
  max-width: 100%;
  max-height: 65vh;
}
/* 拖拽手柄可见性增强（部分浏览器默认手柄偏小） */
.lines-resizable::-webkit-resizer {
  background-color: var(--gray-100);
  background-image: radial-gradient(var(--gray-400) 1px, transparent 1px);
  background-size: 4px 4px;
}

/* ===== v2.5：独立小对话框（新增客户 / 文件删除确认） ===== */
/* 独立于 #modal-root，叠在普通 modal（z-index:1000）之上，用于"弹窗内再弹窗"场景 */
.mini-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}
.mini-dialog {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: mini-dialog-in 0.18s ease-out;
}
.mini-dialog-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mini-dialog-header h3 { font-size: 15px; font-weight: 600; margin: 0; }
.mini-dialog-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.mini-dialog-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
@keyframes mini-dialog-in {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* v2.5.3 销售/采购开票：累计摘要 banner + 表格单元格格式 */
.inv-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 18px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--gray-50, #f7f8fa);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200, #e5e7eb);
}
.inv-summary > div { display: flex; flex-direction: column; gap: 4px; }
.inv-summary .lbl { font-size: 12px; color: var(--gray-600, #4b5563); }
.inv-summary .val { font-size: 15px; color: var(--gray-900, #111827); }
.inv-summary .val b { font-weight: 700; }
.inv-summary.over-limit { color: var(--danger, #dc2626); }
.inv-summary.over-limit .val b { color: var(--danger, #dc2626); }
.inv-net, .inv-tax { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* v2.6 合同统计：颜色预警图例 */
.stat-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--gray-50, #f7f8fa);
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: var(--radius);
}
.stat-legend .badge { pointer-events: none; }

/* v2.7 合同毛利测算：底部汇总条 */
.stat-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--gray-50, #f7f8fa);
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: var(--radius);
}
.stat-summary > div { display: flex; flex-direction: column; gap: 4px; }
.stat-summary .lbl { font-size: 12px; color: var(--gray-500, #6b7280); }
.stat-summary .val { font-size: 16px; color: var(--gray-800, #1f2937); }
