/* ============================================================
   styles.css — 发票大王 v1.1
   设计语言：简约手绘、纸感界面、数据优先
   ============================================================ */

/* ─── Reset & Variables ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* 品牌色 */
  --primary:      #243b53;
  --primary-dim:  #102a43;
  --primary-pale: #f4efe2;
  --accent:       #e0a11b;
  --accent-pale:  #fff2bf;
  --success:      #2f855a;
  --success-dim:  #276749;
  --success-pale: #eefbf3;
  --warn:         #b7791f;
  --warn-pale:    #fff8dd;
  --danger:       #c05621;
  --danger-pale:  #fff1eb;
  --info:         #2b6cb0;

  /* 中性色 */
  --gray-50:  #fffdf7;
  --gray-100: #f7f2e7;
  --gray-200: #eadfcb;
  --gray-300: #d5c3a3;
  --gray-400: #a88f72;
  --gray-500: #7b6a58;
  --gray-600: #5c4f43;
  --gray-700: #3d342c;
  --gray-800: #2b2118;
  --gray-900: #1a130d;

  /* 文字 */
  --text:       var(--gray-800);
  --text-sub:   var(--gray-600);
  --text-muted: var(--gray-500);

  /* 背景 */
  --bg:      #f6efe2;
  --surface: #fffdf7;
  --border:  #dcc9a7;

  /* 尺寸 */
  --topbar-h: 64px;
  --sidebar-w: 304px;
  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;

  /* 阴影 */
  --shadow-sm: 0 2px 0 rgba(36,59,83,.08), 0 1px 3px rgba(43,33,24,.08);
  --shadow:    0 10px 30px rgba(43,33,24,.10);
  --shadow-lg: 0 20px 56px rgba(43,33,24,.16);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.75), transparent 28%),
    linear-gradient(180deg, #fbf5ea 0%, #f6efe2 100%);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Topbar ─── */
/* 书签收藏提示（行内小字，位于按钮区左侧） */
.bookmark-hint-inline {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 4px;
}
.bookmark-hint-inline kbd {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 10px;
  color: var(--text-sub);
  box-shadow: 0 1px 0 var(--border);
  line-height: 1.4;
}

.topbar {
  min-height: var(--topbar-h);
  background: rgba(255, 253, 247, .94);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  flex-shrink: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo-wrap {
  width: 42px;
  height: 42px;
  padding: 5px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, #fffaf0 0%, #fff3cc 100%);
  box-shadow: 0 3px 0 rgba(36,59,83,.10);
  transform: rotate(-3deg);
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .3px;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-ver {
  font-size: 11px;
  color: var(--primary);
  background: var(--accent-pale);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1.5px solid rgba(36,59,83,.18);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s ease;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled {
  opacity: .38;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-icon { font-size: 14px; }

/* Primary */
.btn-primary {
  background: linear-gradient(180deg, #2f4b63 0%, var(--primary) 100%);
  color: #fffdf7;
  border-color: var(--primary);
  box-shadow: 0 4px 0 rgba(16,42,67,.16);
}
.btn-primary:not(:disabled):hover {
  background: linear-gradient(180deg, #28465f 0%, var(--primary-dim) 100%);
  transform: translateY(-1px) rotate(-.4deg);
  box-shadow: 0 7px 18px rgba(36,59,83,.22);
}

/* Success */
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  box-shadow: 0 1px 3px rgba(22,163,74,.3);
}
.btn-success:not(:disabled):hover {
  background: var(--success-dim);
  transform: translateY(-1px);
}

/* Default */
.btn-default {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 2px 0 rgba(36,59,83,.06);
}
.btn-default:not(:disabled):hover {
  background: #fff8ea;
  border-color: var(--gray-300);
}

/* Ghost */
.btn-ghost {
  background: rgba(255,255,255,.45);
  color: var(--text-sub);
  border-color: var(--border);
}
.btn-ghost:not(:disabled):hover {
  background: var(--gray-100);
  color: var(--text);
}

.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ─── Main Layout ─── */
.main-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, rgba(255,253,247,.92) 0%, rgba(255,248,231,.96) 100%);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

/* 拖拽区 */
.drop-zone {
  margin: 16px 14px 0;
  border: 2px dashed var(--gray-300);
  border-radius: 22px;
  padding: 20px 14px 18px;
  text-align: center;
  cursor: pointer;
  transition: all .18s ease;
  background: linear-gradient(180deg, #fffdf7 0%, #fff6da 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55), 0 4px 0 rgba(36,59,83,.06);
  flex-shrink: 0;
}
.drop-zone:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fffdf7 0%, #fff0bc 100%);
}
.drop-zone.drag-over {
  border-color: var(--primary);
  border-style: solid;
  background: linear-gradient(180deg, #fffaf0 0%, #ffeeb2 100%);
  transform: translateY(-1px) scale(1.01);
}
.drop-doodle {
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;
  padding: 8px;
  border-radius: 24px;
  border: 2px solid rgba(36,59,83,.12);
  background: rgba(255,255,255,.72);
  box-shadow: 0 4px 0 rgba(36,59,83,.06);
  transform: rotate(-5deg);
}
.drop-doodle img {
  width: 100%;
  height: 100%;
  display: block;
}
.drop-title { font-size: 16px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.drop-sub   { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; }
.drop-formats {
  font-size: 10px;
  color: var(--text-sub);
  background: rgba(255,255,255,.75);
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  letter-spacing: .2px;
}

/* 文件选择按钮区 */
.file-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  flex-shrink: 0;
}
.file-actions .btn {
  flex: 1;
  justify-content: center;
}

/* 文件统计栏 */
.sidebar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 4px;
  font-size: 11px;
  color: var(--text-sub);
  flex-shrink: 0;
}
.file-count { font-weight: 600; }

/* 文件列表 */
.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  list-style: none;
}

.sidebar-corner-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px dashed rgba(36,59,83,.12);
  background: linear-gradient(180deg, rgba(255,253,247,.72) 0%, rgba(255,248,231,.96) 100%);
  flex-shrink: 0;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background .1s;
}
.file-item:hover { background: var(--gray-50); }
.file-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.badge-xml  { background: #dbeafe; color: #1e40af; }
.badge-ofd  { background: #dcfce7; color: #166534; }
.badge-pdf  { background: #fee2e2; color: #991b1b; }
.badge-img  { background: #fef3c7; color: #92400e; }
.file-name {
  flex: 1;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.file-status { font-size: 13px; flex-shrink: 0; }

/* ─── Content Area ─── */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.corner-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1.5px solid rgba(36,59,83,.14);
  background: rgba(255,253,247,.92);
  color: var(--text-sub);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(36,59,83,.08);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, color .15s ease;
}

.corner-entry:hover {
  transform: translateY(-1px);
  border-color: var(--border);
  background: #fffaf0;
  color: var(--text);
}

.corner-entry svg {
  width: 14px;
  height: 14px;
  display: block;
}

.corner-entry-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-pale);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  border: 1px solid rgba(36,59,83,.12);
}

.skill-guide-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(420px, calc(100% - 36px));
  padding: 14px;
  border-radius: 18px;
  border: 1.5px solid var(--border);
  background: rgba(255,253,247,.97);
  box-shadow: var(--shadow);
  z-index: 13;
}

.skill-guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.skill-guide-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.skill-guide-sub {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-sub);
}

.skill-guide-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.skill-guide-list li {
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.6;
}

.skill-guide-list li:last-child {
  margin-bottom: 0;
}

.skill-guide-prompt-box {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(36,59,83,.12);
  background: linear-gradient(180deg, rgba(255,252,243,.98) 0%, rgba(255,246,224,.94) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 6px 18px rgba(36,59,83,.06);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.skill-guide-prompt-box:hover {
  transform: translateY(-1px);
  border-color: rgba(228,140,56,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.84), 0 10px 24px rgba(36,59,83,.08);
}

.skill-guide-prompt-box:focus {
  outline: none;
  border-color: rgba(228,140,56,.38);
  box-shadow: 0 0 0 3px rgba(228,140,56,.12), inset 0 1px 0 rgba(255,255,255,.84), 0 10px 24px rgba(36,59,83,.08);
}

.skill-guide-prompt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.skill-guide-prompt-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(36,59,83,.1);
  color: var(--text-sub);
  font-size: 10px;
  font-weight: 700;
}

.skill-guide-prompt-state {
  color: var(--text-muted);
  font-size: 10px;
}

.skill-guide-prompt-text {
  color: var(--text);
  font-size: 12px;
  line-height: 1.75;
  word-break: break-word;
}


.skill-guide-note {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-sub);
  background: rgba(255,255,255,.72);
  border: 1px dashed rgba(36,59,83,.16);
  border-radius: 12px;
  padding: 8px 10px;
}

.skill-guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}


/* ─── Empty State ─── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 40px;
  text-align: center;
}
.empty-logo-card {
  width: 112px;
  height: 112px;
  border-radius: 34px;
  padding: 14px;
  background: linear-gradient(180deg, #fffdf7 0%, #fff1c9 100%);
  border: 2px solid rgba(36,59,83,.12);
  box-shadow: 0 10px 0 rgba(36,59,83,.06);
  transform: rotate(-4deg);
}
.empty-logo {
  width: 100%;
  height: 100%;
  display: block;
}
.empty-title { font-size: 24px; font-weight: 800; color: var(--text); }
.empty-sub {
  font-size: 14px;
  color: var(--text-sub);
  max-width: 420px;
  line-height: 1.8;
}
.empty-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-sub);
  background: rgba(255,255,255,.75);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
}

/* ─── Issues Banner ─── */
.issues-banner {
  padding: 0;
  background: var(--warn-pale);
  border-bottom: 1px solid #fcd34d;
  font-size: 12px;
  flex-shrink: 0;
}
.issues-banner-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
}
.issues-toggle {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
}
/* 折叠时只显示「展开」文字，展开时显示「收起」 */
.issues-toggle .issues-toggle-hide { display: none; }
.issues-banner.issues-expanded .issues-toggle .issues-toggle-show { display: none; }
.issues-banner.issues-expanded .issues-toggle .issues-toggle-hide { display: inline; }
/* 详情区 */
.issues-detail {
  display: none;
  padding: 4px 20px 10px;
  border-top: 1px dashed #fcd34d;
}
.issues-banner.issues-expanded .issues-detail { display: block; }
.issues-detail-row {
  font-size: 11px;
  color: var(--text);
  padding: 3px 0;
  line-height: 1.6;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.issues-file {
  font-family: 'SF Mono','Menlo',monospace;
  color: var(--text-sub);
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 60px;
}
.issues-code {
  font-weight: 700;
  color: var(--warn);
  flex-shrink: 0;
}
.issues-suggestion {
  color: var(--text-muted);
  font-size: 10px;
  margin-left: 4px;
}
.issues-banner .issue-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.issue-tag-error  { background: #fee2e2; color: var(--danger); }
.issue-tag-warn   { background: var(--warn-pale); color: var(--warn); border: 1px solid #fcd34d; }
.issues-hint { font-size: 11px; color: var(--text-muted); }

/* ─── Table ─── */
.table-wrap {
  flex: 1;
  overflow: auto;
}
.result-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
  font-size: 12px;
}
.result-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  color: var(--gray-600);
  background: #fbf6ea;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.result-table td {
  padding: 10px 14px;
  border-bottom: 1px dashed rgba(168,143,114,.24);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  color: var(--text);
}
.result-table tbody tr {
  cursor: pointer;
  transition: background .1s;
}
.result-table tbody tr:hover { background: #fff7dd; }
.row-warn  { background: var(--warn-pale) !important; }
.row-error { background: var(--danger-pale) !important; }

.col-amount { color: #7c3aed; font-weight: 700; font-variant-numeric: tabular-nums; }
.col-status { text-align: center; font-size: 14px; }
.col-newname { font-family: 'SF Mono', 'Menlo', 'Consolas', monospace; font-size: 11px; color: var(--gray-600); }

/* ─── Progress ─── */
.progress-wrap {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.progress-label { font-size: 12px; font-weight: 600; color: var(--text); }
.progress-pct   { font-size: 11px; color: var(--text-sub); }
.progress-track {
  height: 4px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .35s ease;
}

/* ─── Shared Drawer base ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.35);
  z-index: 100;
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  box-shadow: -4px 0 40px rgba(0,0,0,.16);
  z-index: 101;
  display: flex;
  flex-direction: column;
  animation: slideIn .2s cubic-bezier(.4,0,.2,1);
}
@keyframes slideIn {
  from { transform: translateX(48px); opacity: .5 }
  to   { transform: translateX(0);    opacity: 1  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.drawer-subtitle {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}
.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

/* ─── Table Toolbar ─── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1.5px solid var(--border);
  background: rgba(255,253,247,.92);
  flex-shrink: 0;
}
.table-toolbar-hint { font-size: 11px; color: var(--text-sub); }
.col-picker-wrap { position: relative; }
.col-picker-menu {
  position: fixed;   /* 用 fixed 脱离滚动容器，由 JS 动态设置 top/right */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 160px;
  padding: 6px 0;
  display: none;     /* 默认隐藏，JS 用 .col-picker-open 切换 */
  max-height: 70vh;
  overflow-y: auto;
}
.col-picker-menu.col-picker-open { display: block; }
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background .1s;
  user-select: none;
}
.col-picker-item:hover { background: var(--gray-50); }
.col-picker-item input[type="checkbox"] { accent-color: var(--primary); }
.col-picker-caret { font-size: 10px; }

/* ─── Invoice Modal ─── */
.invoice-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.invoice-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(3px);
  animation: fadeIn .15s ease;
}
.invoice-modal-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1300px;
  margin: 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 80px rgba(0,0,0,.25);
  overflow: hidden;
  animation: modalIn .2s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn {
  from { transform: scale(.96) translateY(10px); opacity: .5 }
  to   { transform: scale(1)   translateY(0);    opacity: 1  }
}
.invoice-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
  flex-shrink: 0;
  gap: 12px;
}
.modal-nav { display: flex; align-items: center; gap: 8px; }
.modal-index-text { font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; min-width: 48px; text-align: center; }
.modal-filename { flex: 1; font-size: 12px; font-weight: 600; color: var(--text-sub); font-family: 'SF Mono','Menlo','Consolas',monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-modal-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 左侧预览面板 */
.invoice-preview-panel {
  flex: 0 0 62%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--gray-50);
  overflow: hidden;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.preview-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.preview-zoom { display: flex; align-items: center; gap: 4px; }
.zoom-text { font-size: 11px; color: var(--text-sub); font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; }
.preview-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
}
.preview-content {
  transform-origin: top center;
  transition: transform .2s;
}
.preview-content canvas {
  display: block;
  border-radius: 4px;
  box-shadow: var(--shadow);
  max-width: 100%;
}
.preview-content img {
  display: block;
  max-width: 100%;
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.preview-xml {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 11px;
  font-family: 'SF Mono','Menlo','Consolas',monospace;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 100%;
  overflow: auto;
  color: var(--gray-700);
  width: 100%;
}

/* XML 字段卡片预览 */
.xml-preview-card {
  width: 100%;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.xml-preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}
.xml-preview-icon {
  font-size: 22px;
}
.xml-preview-fields {
  padding: 6px 0;
}
.xml-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 18px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}
.xml-preview-row:last-child {
  border-bottom: none;
}
.xml-preview-label {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 72px;
}
.xml-preview-val {
  font-size: 13px;
  color: var(--gray-800);
  text-align: right;
  word-break: break-all;
}
.xml-preview-hint {
  padding: 10px 18px;
  font-size: 11px;
  color: var(--gray-400);
  text-align: center;
  background: var(--gray-50);
  border-top: 1px solid var(--border);
}
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px;
  text-align: center;
}
.preview-placeholder .ph-icon { font-size: 48px; }

/* 右侧字段面板 */
.invoice-fields-panel {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.field-group { margin-bottom: 20px; }
.field-group-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-100);
}
.field-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-50);
}
.field-row:last-child { border-bottom: none; }
.field-key {
  font-size: 12px;
  color: var(--text-sub);
  flex-shrink: 0;
  min-width: 90px;
}
.field-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}
.field-val.editable {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: border-color .15s;
}
.field-val.editable:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
}
.field-val.editing {
  outline: none;
  border-color: var(--primary);
  background: var(--primary-pale);
}

/* 质检问题 */
.issue-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 12px;
}
.issue-item.level-error   { background: var(--danger-pale); color: var(--danger); }
.issue-item.level-warning { background: var(--warn-pale); color: var(--warn); }
.issue-item.level-info    { background: #eff6ff; color: var(--info); }
.issue-code { font-weight: 800; font-size: 11px; margin-right: 5px; }
.issue-suggestion { font-size: 11px; opacity: .75; margin-top: 3px; }

/* ─── Renamer Drawer ─── */
.rule-drawer .drawer { width: 400px; }

.rule-section { margin-bottom: 22px; }
.rule-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.rule-section-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* 规则编辑器 */
.rule-editor {
  min-height: 44px;
  padding: 10px;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  transition: border-color .15s;
}
.rule-editor:hover { border-color: var(--primary); }
.rule-editor-empty {
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Token 胶囊 */
.rule-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  cursor: grab;
  user-select: none;
  transition: transform .1s, box-shadow .1s;
}
.rule-token:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.rule-token.dragging { opacity: .35; cursor: grabbing; }
.rule-token-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: .55;
  padding: 0;
  line-height: 1;
  margin-left: 1px;
  color: inherit;
}
.rule-token-del:hover { opacity: 1; }
.rule-token-separator {
  background: var(--surface);
  color: var(--text-sub);
  border: 1.5px solid var(--border);
  font-family: 'SF Mono', 'Menlo', monospace;
}

/* 字段库 */
.rule-library {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lib-chip {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, opacity .1s;
  border: 1.5px solid transparent;
}
.lib-chip:hover { transform: translateY(-1px); opacity: .85; }

/* 字段库分组 */
.lib-group {
  width: 100%;
  margin-top: 10px;
}
.lib-group:first-child { margin-top: 0; }
.lib-group-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.lib-group-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.sep-chip {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--gray-100);
  color: var(--text);
  border: 1.5px solid var(--border);
  font-family: 'SF Mono', 'Menlo', monospace;
  transition: background .1s;
}
.sep-chip:hover { background: var(--gray-200); }

/* 自定义字段行内输入区 */
.custom-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}
.custom-inline-input {
  height: 26px;
  padding: 0 10px;
  border: 1.5px dashed var(--border);
  border-radius: 99px;
  font-size: 11px;
  background: transparent;
  color: var(--text);
  outline: none;
  width: 140px;
  transition: border-color .15s;
}
.custom-inline-input:focus {
  border-color: var(--primary);
  border-style: solid;
}
.custom-inline-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gray-100);
  border: 1.5px solid var(--border);
  color: var(--text-sub);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, color .1s;
  padding: 0;
  flex-shrink: 0;
}
.custom-inline-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 自定义 token 行内编辑 */
.custom-token-label {
  cursor: text;
  border-bottom: 1px dashed currentColor;
  opacity: .9;
}
.custom-token-label:hover { opacity: 1; }
.custom-token-edit {
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  padding: 0;
  min-width: 30px;
  border-bottom: 1px solid currentColor;
}

/* 预览框 */
.rule-preview-box {
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--primary);
  font-weight: 600;
  word-break: break-all;
  line-height: 1.7;
  min-height: 44px;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s cubic-bezier(.4,0,.2,1);
  max-width: 340px;
  line-height: 1.5;
  pointer-events: auto;
}
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0 }
  to   { transform: translateX(0);   opacity: 1 }
}
.toast-info    { background: var(--primary); }
.toast-success { background: var(--success); }
.toast-warn    { background: var(--warn); }
.toast-error   { background: var(--danger); }

/* ─── Tax Category Badge ─── */
.tax-cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.6;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ─── Responsive ─── */
@media (max-width: 1180px) {
  .topbar {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
    height: auto;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }

  .sidebar-corner-entry {
    gap: 6px;
    padding: 8px 10px 12px;
  }

  .corner-entry {
    height: 30px;
    padding: 0 8px;
    font-size: 10px;
  }

  .skill-guide-panel {
    left: 10px;
    bottom: 10px;
    width: min(320px, calc(100% - 20px));
  }

  .brand-tagline {
    display: none;
  }

  .empty-title {
    font-size: 20px;
  }
}

/* ══════════════════════════════════════════════════════
   发票 HTML 模板样式（InvoiceRenderer）
   模拟全电发票版式：横版，白底，红色标题边框
   ══════════════════════════════════════════════════════ */

/* 外层容器 */
.inv-wrap {
  width: 100%;
  max-width: 740px;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-family: "SimSun", "宋体", "STSong", serif;
  font-size: 11px;
  color: #111;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  overflow: hidden;
  line-height: 1.4;
}

/* ① 顶部标题区 */
.inv-header {
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid #c00;
  min-height: 72px;
}
.inv-header-left {
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-right: 1px solid #e0e0e0;
}
.inv-header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
}
.inv-header-right {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 12px;
  border-left: 1px solid #e0e0e0;
  gap: 4px;
}

/* 二维码占位 */
.inv-qr-box {
  width: 56px;
  height: 56px;
  border: 1.5px solid #999;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
  overflow: hidden;
}
.inv-qr-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.inv-qr-grid {
  width: 30px;
  height: 30px;
  background:
    linear-gradient(45deg, #bbb 25%, transparent 25%),
    linear-gradient(-45deg, #bbb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #bbb 75%),
    linear-gradient(-45deg, transparent 75%, #bbb 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
  opacity: .4;
}
.inv-qr-label {
  font-size: 7px;
  color: #999;
  text-align: center;
  line-height: 1.3;
}

/* 标题框 */
.inv-title-box {
  text-align: center;
}
.inv-title-main {
  font-size: 18px;
  font-weight: 700;
  color: #c00;
  letter-spacing: 2px;
  border: 2px solid #c00;
  padding: 4px 16px;
  border-radius: 2px;
  display: inline-block;
  white-space: nowrap;
}

/* 右侧元数据 */
.inv-meta-row {
  display: flex;
  align-items: baseline;
  font-size: 10px;
}
.inv-meta-key {
  color: #555;
  white-space: nowrap;
  flex-shrink: 0;
}
.inv-meta-val {
  color: #111;
  font-weight: 600;
  word-break: break-all;
}
.inv-val-highlight {
  color: #c00;
  font-size: 11px;
}
.inv-monospace {
  font-family: "Courier New", monospace;
  letter-spacing: .5px;
}

/* ② 购买方/销售方双列 */
.inv-parties {
  display: flex;
  border-bottom: 1px solid #c00;
  min-height: 68px;
}
.inv-party {
  flex: 1;
  display: flex;
  align-items: stretch;
}
.inv-party-label {
  writing-mode: vertical-lr;
  text-orientation: upright;
  background: #fafafa;
  border-right: 1px solid #ddd;
  padding: 6px 4px;
  font-size: 10px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 4px;
  font-weight: 600;
  min-width: 20px;
}
.inv-party-fields {
  flex: 1;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.inv-party-divider {
  width: 1px;
  background: #c00;
  flex-shrink: 0;
}
.inv-party-row {
  display: flex;
  align-items: baseline;
  font-size: 10px;
  gap: 4px;
}
.inv-party-row-sm {
  font-size: 9px;
  color: #555;
}
.inv-party-key {
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 72px;
}
.inv-party-value {
  color: #111;
  word-break: break-all;
}
.inv-party-name {
  font-weight: 600;
  font-size: 11px;
}

/* ③ 商品明细表 */
.inv-goods-section {
  border-bottom: 1px solid #ddd;
}
.inv-goods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}
.inv-goods-table th {
  background: #fafafa;
  border: 1px solid #ddd;
  padding: 4px 6px;
  text-align: center;
  font-weight: 600;
  color: #444;
  white-space: nowrap;
}
.inv-goods-table td {
  border: 1px solid #ddd;
  padding: 5px 6px;
  text-align: center;
  color: #111;
  vertical-align: middle;
}
.inv-col-goods { width: 28%; text-align: left !important; }
.inv-col-spec   { width: 8%; }
.inv-col-unit   { width: 6%; }
.inv-col-qty    { width: 8%; }
.inv-col-price  { width: 12%; }
.inv-col-amount { width: 14%; }
.inv-col-taxrate{ width: 8%; }
.inv-col-tax    { width: 16%; }
.inv-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.inv-empty-row td { height: 22px; }

/* ④ 合计行 */
.inv-total-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  padding: 4px 0;
  font-size: 10px;
}
.inv-total-label {
  flex: 0 0 auto;
  font-weight: 700;
  padding: 0 10px;
  border-right: 1px solid #ddd;
  color: #444;
  white-space: nowrap;
}
.inv-total-spacer       { flex: 1; }
.inv-total-amount       { flex: 0 0 14%; text-align: right; padding-right: 6px; font-variant-numeric: tabular-nums; border-right: 1px solid #ddd; }
.inv-total-taxrate-spacer{ flex: 0 0 8%; border-right: 1px solid #ddd; }
.inv-total-tax          { flex: 0 0 16%; text-align: right; padding-right: 6px; font-variant-numeric: tabular-nums; }

/* ⑤ 价税合计 */
.inv-grand-total {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  padding: 5px 10px;
  gap: 12px;
  font-size: 10px;
}
.inv-grand-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.inv-grand-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.inv-grand-key {
  color: #555;
  white-space: nowrap;
}
.inv-grand-big {
  font-weight: 700;
  font-size: 11px;
  color: #111;
  word-break: break-all;
}
.inv-grand-num {
  font-weight: 700;
  font-size: 13px;
  color: #c00;
  font-variant-numeric: tabular-nums;
}

/* ⑥ 底部 */
.inv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 10px;
  background: #fafafa;
}
.inv-footer-remark {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex: 1;
}
.inv-footer-key   { color: #666; white-space: nowrap; }
.inv-footer-val   { color: #444; }
.inv-footer-badge { flex-shrink: 0; }

/* 来源标签 */
.inv-source-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: "SF Mono","Menlo","Consolas",monospace;
}
.inv-source-xml  { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.inv-source-ofd  { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.inv-source-pdf  { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.inv-source-img  { background: #fdf4ff; color: #9333ea; border: 1px solid #e9d5ff; }
