/* ============= Zap 数据查询平台 v2 ============= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0; padding: 0; background: #fafbfc; color: #1f2937;
  font-size: 14px; line-height: 1.5;
}
code { background: #f3f4f6; padding: 0.05rem 0.3rem; border-radius: 3px; font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; color: #374151; }

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem; background: #1f2937; color: #fff;
  border-bottom: 3px solid #2563eb;
  position: sticky; top: 0; z-index: 100;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; padding: .25rem .5rem; }
.topbar .nav-toggle { display: none; background: transparent; color: #fff; border: 0; font-size: 1.5rem; cursor: pointer; padding: .25rem .5rem; }
.main-nav { display: flex; gap: 0.5rem; flex: 1; margin-left: 1rem; flex-wrap: wrap; }
.main-nav a { color: #cbd5e1; text-decoration: none; padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.9rem; }
.main-nav a:hover { background: #374151; color: #fff; }
.user-info { display: flex; gap: .5rem; align-items: center; }
.user-info .user-name { color: #cbd5e1; font-size: 0.85rem; }
.user-info .logout-btn { background: transparent; color: #cbd5e1; border: 1px solid #4b5563; padding: .2rem .6rem; border-radius: 3px; cursor: pointer; font-size: 0.85rem; }
.user-info .logout-btn:hover { background: #374151; color: #fff; }

/* ===== 容器 ===== */
.container { padding: 0.6rem; max-width: 100%; }
.footer { padding: 0.6rem; color: #6b7280; border-top: 1px solid #e5e7eb; margin-top: 1rem; font-size: 0.8rem; }
.page-title { font-size: 1.1rem; margin: 0; line-height: 1.3; }
.page-heading { display: flex; align-items: baseline; gap: 0.45rem; min-width: 0; }
.page-total { color: #6b7280; font-size: 0.72rem; white-space: nowrap; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
.btn { background: #2563eb; color: #fff; padding: 0.25rem 0.5rem; border-radius: 4px; text-decoration: none; font-size: 0.75rem; display: inline-block; white-space: nowrap; }
.btn:hover { background: #1d4ed8; }
.hint { color: #6b7280; font-size: 0.8rem; }
.muted { color: #9ca3af; }

/* ===== 首页表卡片 ===== */
.table-cards { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 1rem; }
.table-card {
  background: #fff; border-radius: 6px; padding: 0.8rem 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid #e5e7eb;
}
.table-card:hover { border-color: #2563eb; }
.table-card-name { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.table-card-name a { color: #2563eb; text-decoration: none; font-weight: 600; font-size: 1rem; }
.table-card-name code { font-size: 0.75rem; color: #6b7280; }
.table-card-meta { display: flex; gap: 0.8rem; font-size: 0.8rem; color: #6b7280; flex-wrap: wrap; }

/* ===== 筛选条 ===== */
.filter-bar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding: 0.25rem 0; margin-bottom: 0.35rem; }
.filter-meta { color: #6b7280; font-size: 0.75rem; white-space: nowrap; }
.filter-meta strong { color: #1f2937; font-weight: 600; }
.filter-controls { display: flex; align-items: center; gap: 0.3rem; min-width: 0; flex: 1; }
.page-size-label { color: #6b7280; font-size: 0.72rem; white-space: nowrap; }
.quick-filters { display: flex; align-items: center; gap: 0.3rem; min-width: 0; }
.select { padding: .2rem .35rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.75rem; background: #fff; }
.select-sm { padding: .15rem .3rem; font-size: 0.7rem; }
.filter-btn { display: inline-block; color: #2563eb; cursor: pointer; padding: 0.15rem 0.4rem; border: 1px solid #2563eb; border-radius: 3px; font-size: 0.7rem; text-decoration: none; white-space: nowrap; line-height: 1.3; }
.filter-btn:hover { background: #eff6ff; }
.filter-btn.active { background: #2563eb; color: #fff; }

/* ===== 筛选行(列筛选输入框) ===== */
.filter-row { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0; border-top: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; margin-bottom: 0.75rem; }
.filter-input { flex: 1; min-width: 110px; padding: 0.3rem 0.4rem; border: 1px solid #d1d5db; border-radius: 3px; font-size: 0.78rem; }
.filter-input:focus { outline: 2px solid #2563eb; border-color: #2563eb; }

/* ===== 桌面表格(默认隐藏在移动端) ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
table.grid th, table.grid td { padding: 0.45rem 0.55rem; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; font-size: 0.82rem; }
table.grid th { background: #f3f4f6; font-weight: 600; position: sticky; top: 0; }
table.grid tr:hover { background: #f9fafb; }
table.grid.small { font-size: 0.78rem; }
table.grid.small th, table.grid.small td { padding: 0.3rem 0.4rem; }
.col-head a { color: #1f2937; text-decoration: none; }
.col-head a:hover { color: #2563eb; }
.merged-col .badge-merged { display: inline-block; background: #dbeafe; color: #1e40af; font-size: 0.65rem; padding: 0.05rem 0.3rem; border-radius: 3px; margin-bottom: 0.2rem; }
.dict-col .badge-dict { display: inline-block; background: #d1fae5; color: #065f46; font-size: 0.65rem; padding: 0.05rem 0.3rem; border-radius: 3px; margin-bottom: 0.2rem; }
.dict-col strong { color: #1f2937; }
.dict-col small.muted { display: inline-block; margin-left: 0.3rem; color: #9ca3af; font-size: 0.7rem; }
table.detail-table td strong { color: #1f2937; font-weight: 600; }
.contract-col .badge-contract { display: inline-block; background: #fef3c7; color: #92400e; font-size: 0.65rem; padding: 0.05rem 0.3rem; border-radius: 3px; margin-bottom: 0.2rem; }
.contract-link { color: #2563eb; font-weight: 600; text-decoration: none; }
.contract-link:hover { text-decoration: underline; }

/* 合同汇总卡 */
.contract-summary { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 1rem; }
.contract-summary h2 { margin: 0 0 .6rem; font-size: 1rem; color: #92400e; }
.contract-summary h2 small { font-weight: 400; color: #a16207; font-size: .75rem; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.summary-item { display: flex; flex-direction: column; background: #fff; border: 1px solid #fef3c7; border-radius: 6px; padding: .5rem .6rem; }
.summary-num { font-size: 1.1rem; font-weight: 700; color: #92400e; }
.summary-label { font-size: .75rem; color: #a16207; }
.btn-sm { font-size: .8rem; padding: .3rem .7rem; }
.pk-cell a { color: #2563eb; font-weight: 500; text-decoration: none; }
.pk-cell a:hover { text-decoration: underline; }
.empty { color: #9ca3af; text-align: center; padding: 1.5rem; }

/* ===== 移动端卡片(默认隐藏) ===== */
.table-cards-mobile { display: none; }
.mobile-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; }
.mobile-row { display: flex; padding: 0.25rem 0; border-bottom: 1px dashed #f3f4f6; font-size: 0.85rem; gap: 0.5rem; }
.mobile-row:last-child { border-bottom: 0; }
.mobile-key { color: #6b7280; min-width: 5em; flex-shrink: 0; font-size: 0.8rem; }
.mobile-val { flex: 1; word-break: break-word; }
.mobile-val a { color: #2563eb; text-decoration: none; font-weight: 500; }

/* ===== 分页 ===== */
.pagination { display: flex; gap: 0.5rem; align-items: center; padding: 0.75rem 0; flex-wrap: wrap; }
.pagination a { padding: 0.3rem 0.7rem; background: #fff; border: 1px solid #d1d5db; border-radius: 4px; text-decoration: none; color: #2563eb; font-size: 0.85rem; }
.pagination a:hover { background: #f3f4f6; }
.page-jump { color: #6b7280; font-size: 0.85rem; margin-left: auto; }
.page-jump-input { width: 4em; padding: 0.2rem 0.3rem; border: 1px solid #d1d5db; border-radius: 3px; }

/* ===== 详情页 ===== */
table.detail-table { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
table.detail-table th, table.detail-table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid #e5e7eb; vertical-align: top; font-size: 0.85rem; }
table.detail-table th { background: #f3f4f6; text-align: left; min-width: 7em; }
table.detail-table td { word-break: break-word; max-width: 100%; }
table.detail-table th small { font-weight: 400; }
pre { background: #f3f4f6; padding: 0.5rem; border-radius: 4px; overflow-x: auto; font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }
.null { color: #9ca3af; font-style: italic; }

.contact-card { background: linear-gradient(135deg, #f0f9ff, #ecfeff); border: 1px solid #bae6fd; border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 1rem; }
.contact-card h2 { margin: 0 0 .5rem; font-size: 1rem; color: #0c4a6e; }
.contact-card.empty-contact { background: #f9fafb; border-color: #e5e7eb; }
.contact-card.empty-contact h2 { color: #6b7280; }
.contact-card dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem; }
.contact-row { display: flex; flex-direction: column; }
.contact-row dt { font-size: 0.75rem; color: #64748b; font-weight: 500; }
.contact-row dd { margin: 0; font-size: 0.95rem; color: #1e293b; word-break: break-word; }

details { margin: 0.6rem 0; border: 1px solid #e5e7eb; border-radius: 4px; padding: 0.5rem 0.75rem; background: #fff; }
details summary { cursor: pointer; font-weight: 500; }

/* ===== 登录页 ===== */
.login-wrap { max-width: 360px; margin: 3rem auto; }
.login-form { background: #fff; padding: 1.5rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.login-form h1 { margin: 0 0 .25rem; font-size: 1.3rem; }
.login-form label { display: block; margin: 0.8rem 0 .25rem; font-weight: 500; }
.login-form input { width: 100%; padding: .55rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 1rem; }
.login-form button { margin-top: 1rem; width: 100%; padding: .65rem; background: #2563eb; color: #fff; border: 0; border-radius: 4px; font-size: 1rem; cursor: pointer; }
.login-form button:hover { background: #1d4ed8; }
.login-form .error { color: #dc2626; background: #fef2f2; padding: .5rem .75rem; border-radius: 4px; font-size: .9rem; }

/* ============= 移动端适配 (≤768px) ============= */
@media (max-width: 768px) {
  .container { padding: 0.45rem 0.5rem; }
  .topbar { padding: 0.5rem; flex-wrap: wrap; }
  .topbar .nav-toggle { display: block; }
  .main-nav { display: none; flex-direction: column; gap: 0; width: 100%; order: 99; margin: 0.5rem 0 0; padding: 0.5rem 0; border-top: 1px solid #374151; }
  body.nav-open .main-nav { display: flex; }
  .main-nav a { width: 100%; padding: 0.6rem 0.5rem; border-radius: 0; font-size: 1rem; }
  .user-info { margin-left: auto; }
  .user-info .user-name { display: none; }

  /* 列表切换: 桌面表格隐藏, 移动卡片显示 */
  .table-wrap { display: none; }
  .table-cards-mobile { display: block; }
  .filter-row { display: none; }
  body.show-filters .filter-row { display: flex; flex-direction: column; }

  /* 筛选输入框占满 */
  .filter-input { width: 100%; }

  /* 隐藏桌面专属 */
  .page-header { align-items: center; margin-bottom: 0.25rem; }
  .page-title { font-size: 1rem; }
  .page-total { font-size: 0.68rem; }
  .actions .btn { padding: 0.24rem 0.42rem; font-size: 0.7rem; }
  .filter-bar { display: block; padding: 0.2rem 0; margin-bottom: 0.35rem; }
  .filter-meta { display: inline-block; margin-right: 0.35rem; }
  .filter-controls { display: inline-flex; vertical-align: middle; flex-wrap: nowrap; gap: 0.25rem; max-width: calc(100% - 0.35rem); }
  .quick-filters { overflow-x: auto; scrollbar-width: none; }
  .quick-filters::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; padding: 0.14rem 0.38rem; font-size: 0.68rem; }
  .filter-toggle { flex-shrink: 0; }
  .pagination { font-size: 0.78rem; gap: 0.35rem; padding: 0.5rem 0; }
  .page-jump { width: auto; margin-left: auto; }
}

@media (max-width: 480px) {
  .page-header { gap: 0.25rem; }
  .page-heading { gap: 0.3rem; }
  .page-title { font-size: 0.98rem; }
  .page-total { font-size: 0.65rem; }
  .actions { gap: 0.2rem; }
  .btn { padding: 0.2rem 0.35rem; font-size: 0.68rem; }
  .filter-bar { padding: 0.15rem 0; margin-bottom: 0.25rem; }
  .filter-meta { font-size: 0.68rem; }
  .filter-controls { max-width: calc(100% - 0.2rem); }
  .filter-btn { padding: 0.12rem 0.32rem; font-size: 0.64rem; }
  .contact-card dl { grid-template-columns: 1fr; }
}
/* ============= 桌面端增强 v20 (≥1024px) ============= */
@media (min-width: 1024px) {
  body { font-size: 14px; }
  .container { padding: 0.8rem 1.2rem; max-width: 1600px; margin: 0 auto; }
  .topbar { padding: 0.55rem 1.2rem; }
  .topbar .brand { font-size: 1.15rem; }
  .main-nav a { font-size: 0.92rem; padding: 0.4rem 0.75rem; }
  .user-info .user-name { color: #cbd5e1; font-size: 0.88rem; }
  .user-info .logout-btn { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

  /* 表格基础 */
  table.grid { font-size: 0.85rem; table-layout: auto; }
  table.grid th { background: #f8fafc; font-weight: 600; font-size: 0.8rem; letter-spacing: 0.01em; padding: 0.55rem 0.6rem; border-bottom: 2px solid #cbd5e1; position: sticky; top: 48px; z-index: 50; box-shadow: inset 0 -1px 0 #cbd5e1; writing-mode: horizontal-tb; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
  table.grid td { padding: 0.45rem 0.6rem; font-size: 0.85rem; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  table.grid td[title] { cursor: help; }
  table.grid tr:nth-child(even) td { background: #fcfcfd; }
  table.grid tr:hover td { background: #eff6ff; }
  table.grid tr:hover td:first-child { background: #dbeafe; }

  /* 数字列 */
  table.grid td.num, table.grid td.numeric, table.grid td.amount { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
  table.grid th.num, table.grid th.amount { text-align: right; }
  table.grid td.pk-cell { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; color: #1e40af; }
  table.grid .dict-col { color: #1f2937; }

  /* 密度 */
  body.density-compact table.grid th, body.density-compact table.grid td { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
  body.density-compact .summary-num { font-size: 1rem; }
  body.density-loose table.grid th, body.density-loose table.grid td { padding: 0.65rem 0.8rem; font-size: 0.9rem; }

  /* 工具栏 */
  .filter-bar { display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem 0.75rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; margin-bottom: 0.6rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
  .toolbar-left { display: flex; gap: 0.75rem; align-items: center; flex: 1; min-width: 0; }
  .toolbar-right { display: flex; gap: 0.4rem; align-items: center; }
  .filter-meta { font-size: 0.85rem; }
  .filter-meta strong { font-size: 1rem; color: #2563eb; font-weight: 700; }
  .quick-filters { gap: 0.4rem; }
  .filter-btn { padding: 0.25rem 0.55rem; font-size: 0.78rem; }
  .density-toggle { display: inline-flex; gap: 2px; background: #f3f4f6; border-radius: 4px; padding: 2px; }
  .density-toggle button { background: transparent; border: 0; padding: 0.2rem 0.5rem; font-size: 0.72rem; color: #6b7280; cursor: pointer; border-radius: 3px; }
  .density-toggle button.active { background: #2563eb; color: #fff; }
  .col-settings-btn, .preset-btn { background: #fff; color: #4b5563; border: 1px solid #d1d5db; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.78rem; cursor: pointer; }
  .col-settings-btn:hover, .preset-btn:hover { background: #f3f4f6; }

  /* 表头单行: 列头第一行吸顶 (顶栏 48px) */
  table.grid thead tr.th-title-row th { top: 48px; z-index: 51; }

  /* 头部 */
  .page-title { font-size: 1.3rem; font-weight: 700; }
  .page-total { font-size: 0.85rem; color: #4b5563; }
  .breadcrumb { font-size: 0.8rem; color: #6b7280; margin-bottom: 0.4rem; }
  .breadcrumb a { color: #2563eb; text-decoration: none; }
  .breadcrumb a:hover { text-decoration: underline; }
  .breadcrumb .sep { margin: 0 0.4rem; color: #9ca3af; }

  /* 排序 */
  table.grid th.col-head { display: table-cell; } /* 仅作 JS 定位标识, 不破坏表格布局 */
  .col-head { display: flex; align-items: center; gap: 0.3rem; writing-mode: horizontal-tb; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .col-head > * { min-width: 0; }
  .col-head .sort-indicator { display: inline-block; width: 0; height: 0; opacity: 0.3; flex-shrink: 0; }
  .col-head .sort-indicator.asc { border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid #2563eb; opacity: 1; }
  .col-head .sort-indicator.desc { border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid #2563eb; opacity: 1; }
  .col-head a { color: #1f2937; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
  .col-head a:hover { color: #2563eb; }
  .col-head.sorted { color: #2563eb; }
  .col-head.sorted a { color: #2563eb; font-weight: 600; }
  .col-head .col-filter-trigger { display: inline-flex; visibility: visible; font-size: 0.65rem; color: #9ca3af; cursor: pointer; padding: 0 0.2rem; opacity: 0; transition: opacity 0.15s; }
  .col-head:hover .col-filter-trigger { visibility: visible; opacity: 1; }
  .col-head.filtered .col-filter-trigger { visibility: visible; opacity: 1; color: #2563eb; }

  /* 冻结首列 */
  table.grid th:first-child, table.grid td:first-child { position: sticky; left: 0; z-index: 40; background: #fff; box-shadow: inset -1px 0 0 #e5e7eb; }
  table.grid tr:nth-child(even) td:first-child { background: #fcfcfd; }
  table.grid tr:hover td:first-child { background: #dbeafe; }
  table.grid thead th:first-child { z-index: 60; background: #f8fafc; }

  /* 列高亮 */
  table.grid th.hl, table.grid td.hl { background: #fef3c7 !important; }
  table.grid th.hl { color: #92400e; }

  /* 右键菜单 */
  .col-context-menu { position: fixed; background: #fff; border: 1px solid #d1d5db; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 0.4rem 0; z-index: 1000; min-width: 160px; font-size: 0.85rem; }
  .col-context-menu .item { padding: 0.4rem 0.7rem; cursor: pointer; }
  .col-context-menu .item:hover { background: #f3f4f6; }
  .col-context-menu .item.danger { color: #dc2626; }
  .col-context-menu hr { margin: 0.3rem 0; border: 0; border-top: 1px solid #e5e7eb; }

  /* 列内筛选气泡 */
  .col-filter-pop { position: absolute; background: #fff; border: 1px solid #d1d5db; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 0.5rem; z-index: 999; min-width: 200px; }
  .col-filter-pop input { width: 100%; padding: 0.3rem 0.4rem; border: 1px solid #d1d5db; border-radius: 3px; font-size: 0.8rem; box-sizing: border-box; }
  .col-filter-pop .pop-actions { display: flex; gap: 0.3rem; margin-top: 0.4rem; }
  .col-filter-pop button { flex: 1; padding: 0.3rem; border: 0; border-radius: 3px; font-size: 0.78rem; cursor: pointer; }
  .col-filter-pop .apply { background: #2563eb; color: #fff; }
  .col-filter-pop .clear { background: #f3f4f6; color: #4b5563; }

  /* 列设置面板 */
  .col-settings-panel { position: fixed; right: 0; top: 0; bottom: 0; width: 320px; background: #fff; border-left: 1px solid #e5e7eb; box-shadow: -4px 0 12px rgba(0,0,0,0.1); padding: 1rem; z-index: 1001; overflow-y: auto; transform: translateX(100%); transition: transform 0.2s; }
  .col-settings-panel.open { transform: translateX(0); }
  .col-settings-panel h3 { margin: 0 0 0.5rem; font-size: 1rem; }
  .col-settings-panel .col-item { display: flex; align-items: center; padding: 0.3rem 0; gap: 0.4rem; font-size: 0.85rem; cursor: move; }
  .col-settings-panel .col-item.dragging { opacity: 0.5; }
  .col-settings-panel .col-item input { margin-right: 0.3rem; }
  .col-settings-panel .col-item .handle { color: #9ca3af; cursor: grab; }
  .col-settings-panel .col-item.always-on { color: #6b7280; }
  .col-settings-panel .quick-actions { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; padding-bottom: 0.6rem; border-bottom: 1px solid #e5e7eb; }
  .col-settings-panel .quick-actions button { flex: 1; padding: 0.3rem; font-size: 0.78rem; border: 1px solid #d1d5db; background: #fff; border-radius: 3px; cursor: pointer; }
  .col-settings-panel .quick-actions button:hover { background: #f3f4f6; }
  .col-settings-panel .close-btn { position: absolute; right: 0.5rem; top: 0.5rem; background: transparent; border: 0; font-size: 1.2rem; cursor: pointer; color: #6b7280; }

  /* 预设 */
  .preset-menu { position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid #d1d5db; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin-top: 0.2rem; min-width: 220px; z-index: 1000; }
  .preset-menu .preset-item { padding: 0.4rem 0.6rem; font-size: 0.85rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
  .preset-menu .preset-item:hover { background: #f3f4f6; }
  .preset-menu .preset-item .del { color: #dc2626; font-size: 0.7rem; padding: 0 0.3rem; }
  .preset-menu .preset-item .del:hover { text-decoration: underline; }

  /* 选中 */
  table.grid tr.selected td { background: #dbeafe !important; }
  table.grid tr.selected td:first-child { background: #93c5fd !important; }
  .select-bar { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 0.6rem 1.2rem; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); display: none; gap: 0.8rem; align-items: center; z-index: 200; font-size: 0.85rem; }
  .select-bar.show { display: flex; }
  .select-bar button { background: #374151; color: #fff; border: 0; padding: 0.3rem 0.7rem; border-radius: 4px; font-size: 0.78rem; cursor: pointer; }
  .select-bar button:hover { background: #4b5563; }
  .select-bar .sum { color: #fbbf24; font-weight: 600; font-variant-numeric: tabular-nums; }

  /* 合计行 */
  table.grid tfoot td { background: #fef3c7 !important; font-weight: 600; border-top: 2px solid #f59e0b; font-variant-numeric: tabular-nums; }

  /* 分页 */
  .pagination { padding: 1rem 0; gap: 0.5rem; font-size: 0.9rem; }
  .pagination a { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
  .page-jump { display: flex; gap: 0.3rem; align-items: center; font-size: 0.85rem; margin-left: auto; }
  .page-jump-input { width: 4em; padding: 0.3rem 0.4rem; font-size: 0.85rem; }

  /* Dashboard */
  .dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
  .dashboard .stat { background: linear-gradient(135deg, #fff, #f8fafc); border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem 1.2rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
  .dashboard .stat h3 { margin: 0; font-size: 0.85rem; color: #6b7280; font-weight: 500; }
  .dashboard .stat .num { font-size: 1.8rem; font-weight: 700; color: #1f2937; margin: 0.3rem 0; font-variant-numeric: tabular-nums; }
  .dashboard .stat .delta { font-size: 0.75rem; color: #059669; }
  .dashboard .stat .delta.down { color: #dc2626; }
  .dashboard .stat a { color: #2563eb; text-decoration: none; font-size: 0.8rem; }
  .dashboard .stat a:hover { text-decoration: underline; }
  .dashboard canvas { margin-top: 0.6rem; max-height: 200px; }
}

/* 桌面端详情/时间线/骨架等 */
@media (min-width: 1024px) {
  /* 详情页双栏 + 关键字段卡片化 */
  .detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.2rem; align-items: start; }
  @media (min-width: 1440px) { .detail-grid { grid-template-columns: 1fr 1fr 1fr; } }
  .detail-grid .key-card { background: linear-gradient(135deg, #fff, #fef3c7); border: 1px solid #fde68a; border-left: 4px solid #f59e0b; border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 0.6rem; }
  .detail-grid .key-card .label { font-size: 0.75rem; color: #92400e; font-weight: 500; }
  .detail-grid .key-card .value { font-size: 1.3rem; color: #1f2937; font-weight: 600; margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
  .detail-grid .key-card .value.big { font-size: 1.6rem; color: #92400e; }
  .detail-grid .key-card .value.status { font-size: 1rem; }

  .detail-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 0.8rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
  .detail-section .section-head { padding: 0.6rem 1rem; background: #f8fafc; border-bottom: 1px solid #e5e7eb; font-weight: 600; font-size: 0.95rem; color: #1f2937; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
  .detail-section.collapsed .section-body { display: none; }
  .detail-section .section-body { padding: 0.6rem 1rem; }
  .detail-section .section-body table { width: 100%; }
  .detail-section .section-body td.key { color: #6b7280; font-size: 0.82rem; padding: 0.3rem 0.6rem 0.3rem 0; width: 35%; vertical-align: top; }
  .detail-section .section-body td.val { padding: 0.3rem 0; font-size: 0.88rem; word-break: break-word; }
  .detail-section .section-body td.val.dict-cell { color: #1f2937; }
  .detail-section .section-body td.val.dict-cell small { color: #9ca3af; font-size: 0.72rem; margin-left: 0.3rem; }
  .detail-section .toggle-icon { color: #9ca3af; transition: transform 0.15s; }
  .detail-section.collapsed .toggle-icon { transform: rotate(-90deg); }
  .detail-section .section-body a.field-link { color: #2563eb; text-decoration: none; }
  .detail-section .section-body a.field-link:hover { text-decoration: underline; }

  /* 合同时间线 */
  .timeline { display: flex; align-items: stretch; gap: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; overflow-x: auto; }
  .timeline .step { flex: 1; min-width: 110px; text-align: center; position: relative; padding: 0 0.5rem; }
  .timeline .step:not(:last-child)::after { content: ''; position: absolute; right: -8px; top: 16px; width: 16px; height: 2px; background: #e5e7eb; }
  .timeline .step.done:not(:last-child)::after { background: #10b981; }
  .timeline .step .dot { width: 32px; height: 32px; border-radius: 50%; background: #e5e7eb; color: #9ca3af; display: flex; align-items: center; justify-content: center; margin: 0 auto 0.4rem; font-size: 0.9rem; font-weight: 600; }
  .timeline .step.done .dot { background: #10b981; color: #fff; }
  .timeline .step.current .dot { background: #f59e0b; color: #fff; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2); }
  .timeline .step .label { font-size: 0.78rem; color: #4b5563; font-weight: 500; }
  .timeline .step .date { font-size: 0.7rem; color: #9ca3af; margin-top: 0.2rem; }
  .timeline .step.current .label { color: #92400e; font-weight: 600; }
  .timeline .step.done .label { color: #065f46; }

  /* 关联合同快捷区 */
  .related-contracts { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 1rem; }
  .related-contracts h3 { margin: 0 0 0.5rem; font-size: 0.95rem; color: #92400e; }
  .related-contracts .contract-row { display: flex; justify-content: space-between; padding: 0.3rem 0; border-bottom: 1px dashed #fde68a; font-size: 0.85rem; }
  .related-contracts .contract-row:last-child { border-bottom: 0; }
  .related-contracts .contract-row a { color: #2563eb; text-decoration: none; }
  .related-contracts .contract-row a:hover { text-decoration: underline; }
  .related-contracts .contract-row .amount { font-variant-numeric: tabular-nums; color: #1f2937; }

  /* 关联表 */
  .related-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 0.8rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
  .related-section h3 { margin: 0; padding: 0.6rem 1rem; background: #f0f9ff; border-bottom: 1px solid #e5e7eb; font-size: 0.95rem; color: #0c4a6e; cursor: pointer; display: flex; justify-content: space-between; }
  .related-section.collapsed h3::after { content: '\25B6'; font-size: 0.7rem; color: #9ca3af; }
  .related-section:not(.collapsed) h3::after { content: '\25BC'; font-size: 0.7rem; color: #9ca3af; }
  .related-section .related-body { padding: 0.6rem 1rem; max-height: 360px; overflow-y: auto; }
  .related-section.collapsed .related-body { display: none; }
  .related-section table.grid { font-size: 0.82rem; }
  .related-section table.grid td { padding: 0.3rem 0.5rem; max-width: 200px; }

  /* 客户详情合同汇总 - 升级 */
  .contract-summary { background: linear-gradient(135deg, #fffbeb, #fef3c7); border: 1px solid #fde68a; border-radius: 8px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
  .contract-summary h2 { font-size: 1.05rem; color: #92400e; margin: 0 0 0.6rem; }
  .summary-grid { grid-template-columns: repeat(6, 1fr); gap: 0.6rem; }
  .summary-item { padding: 0.6rem 0.8rem; }
  .summary-num { font-size: 1.25rem; }
  .summary-label { font-size: 0.78rem; }

  /* 字段类型颜色 */
  .field-type-pk { color: #1e40af; font-weight: 600; }
  .field-type-bool-true { color: #059669; font-weight: 500; }
  .field-type-bool-false { color: #9ca3af; }
  .field-type-money { color: #92400e; font-weight: 600; font-variant-numeric: tabular-nums; }
  .field-type-date { color: #6366f1; font-family: ui-monospace, monospace; font-size: 0.85em; }
  .field-link { color: #2563eb; text-decoration: none; }
  .field-link:hover { text-decoration: underline; }

  /* 骨架屏 */
  .skeleton-row td { padding: 0.5rem 0.6rem; }
  .skeleton-bar { height: 14px; background: linear-gradient(90deg, #f3f4f6, #e5e7eb, #f3f4f6); background-size: 200% 100%; border-radius: 3px; animation: skeleton 1.4s ease-in-out infinite; }
  @keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

  /* 空状态 */
  .empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
  .empty-state .icon { font-size: 3rem; opacity: 0.4; }
  .empty-state h3 { font-size: 1.1rem; color: #4b5563; margin: 0.5rem 0; }
  .empty-state p { font-size: 0.9rem; color: #9ca3af; margin: 0.3rem 0 1rem; }
  .empty-state button { background: #2563eb; color: #fff; border: 0; padding: 0.5rem 1.2rem; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
  .empty-state button:hover { background: #1d4ed8; }

  /* 键盘快捷键提示 */
  .kbd-hint { position: fixed; bottom: 1rem; right: 1rem; background: rgba(31, 41, 55, 0.9); color: #fff; padding: 0.5rem 0.8rem; border-radius: 6px; font-size: 0.75rem; z-index: 90; box-shadow: 0 2px 8px rgba(0,0,0,0.2); opacity: 0.7; }
  .kbd-hint kbd { background: #4b5563; color: #fff; padding: 0.05rem 0.35rem; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.85em; margin: 0 0.1rem; }
}

/* 暗色模式 (>=1024px) */
@media (min-width: 1024px) {
  body.theme-dark { background: #0f172a; color: #e2e8f0; }
  body.theme-dark .topbar { background: #020617; border-bottom-color: #1e40af; }
  body.theme-dark .main-nav a { color: #94a3b8; }
  body.theme-dark .main-nav a:hover { background: #1e293b; color: #fff; }
  body.theme-dark .container { background: #0f172a; }
  body.theme-dark .filter-bar { background: #1e293b; border-color: #334155; }
  body.theme-dark .filter-meta { color: #94a3b8; }
  body.theme-dark .filter-meta strong { color: #60a5fa; }
  body.theme-dark .page-title { color: #f1f5f9; }
  body.theme-dark .page-total { color: #94a3b8; }
  body.theme-dark table.grid { background: #1e293b; }
  body.theme-dark table.grid th { background: #0f172a; color: #cbd5e1; border-bottom-color: #475569; }
  body.theme-dark table.grid td { border-bottom-color: #334155; color: #e2e8f0; }
  body.theme-dark table.grid tr:nth-child(even) td { background: #1a2438; }
  body.theme-dark table.grid tr:hover td { background: #1e3a5f; }
  body.theme-dark table.grid th:first-child, body.theme-dark table.grid td:first-child { background: #1e293b; }
  body.theme-dark table.grid tr:nth-child(even) td:first-child { background: #1a2438; }
  body.theme-dark table.grid thead th:first-child { background: #0f172a; }
  body.theme-dark .col-head a { color: #cbd5e1; }
  body.theme-dark .col-head a:hover { color: #60a5fa; }
  body.theme-dark .col-head.sorted a { color: #60a5fa; }
  body.theme-dark .contract-summary { background: linear-gradient(135deg, #422006, #78350f); border-color: #92400e; }
  body.theme-dark .contract-summary h2 { color: #fbbf24; }
  body.theme-dark .contract-summary h2 small { color: #fde68a; }
  body.theme-dark .summary-item { background: #78350f; border-color: #92400e; }
  body.theme-dark .summary-num { color: #fbbf24; }
  body.theme-dark .summary-label { color: #fde68a; }
  body.theme-dark .detail-section { background: #1e293b; border-color: #334155; }
  body.theme-dark .detail-section .section-head { background: #0f172a; color: #e2e8f0; border-bottom-color: #334155; }
  body.theme-dark .detail-section .section-body td.key { color: #94a3b8; }
  body.theme-dark .detail-section .section-body td.val { color: #e2e8f0; }
  body.theme-dark .key-card { background: linear-gradient(135deg, #422006, #78350f); border-color: #92400e; }
  body.theme-dark .key-card .label { color: #fde68a; }
  body.theme-dark .key-card .value { color: #fef3c7; }
  body.theme-dark .timeline { background: #1e293b; border-color: #334155; }
  body.theme-dark .timeline .step .dot { background: #334155; color: #94a3b8; }
  body.theme-dark .timeline .step.done .dot { background: #10b981; }
  body.theme-dark .timeline .step:not(:last-child)::after { background: #334155; }
  body.theme-dark .pagination a { background: #1e293b; border-color: #334155; color: #60a5fa; }
  body.theme-dark .pagination a:hover { background: #334155; }
  body.theme-dark .col-context-menu, body.theme-dark .col-filter-pop, body.theme-dark .preset-menu, body.theme-dark .col-settings-panel { background: #1e293b; border-color: #334155; color: #e2e8f0; }
  body.theme-dark .col-context-menu .item:hover, body.theme-dark .preset-menu .preset-item:hover, body.theme-dark .col-filter-pop .clear { background: #334155; }
  body.theme-dark .col-filter-pop input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
  body.theme-dark .col-filter-pop .clear { color: #e2e8f0; }
  body.theme-dark .density-toggle { background: #334155; }
  body.theme-dark .density-toggle button { color: #94a3b8; }
  body.theme-dark .density-toggle button.active { background: #2563eb; color: #fff; }
  body.theme-dark .col-settings-btn, body.theme-dark .preset-btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
  body.theme-dark .col-settings-btn:hover, body.theme-dark .preset-btn:hover { background: #334155; }
  body.theme-dark .dashboard .stat { background: linear-gradient(135deg, #1e293b, #0f172a); border-color: #334155; }
  body.theme-dark .dashboard .stat h3 { color: #94a3b8; }
  body.theme-dark .dashboard .stat .num { color: #f1f5f9; }
  body.theme-dark .related-contracts { background: #422006; border-color: #92400e; }
  body.theme-dark .related-contracts h3 { color: #fbbf24; }
  body.theme-dark .related-contracts .contract-row { border-bottom-color: #92400e; }
  body.theme-dark .related-section { background: #1e293b; border-color: #334155; }
  body.theme-dark .related-section h3 { background: #0c4a6e; color: #bae6fd; }
  body.theme-dark .empty-state { color: #94a3b8; }
  body.theme-dark .empty-state h3 { color: #cbd5e1; }
  body.theme-dark .table-card { background: #1e293b; border-color: #334155; }
  body.theme-dark .table-card-name a { color: #60a5fa; }
  body.theme-dark .table-card-meta { color: #94a3b8; }
  body.theme-dark .skeleton-bar { background: linear-gradient(90deg, #1e293b, #334155, #1e293b); background-size: 200% 100%; }
  body.theme-dark .kbd-hint { background: rgba(2, 6, 23, 0.95); }
  body.theme-dark .select-bar { background: #020617; }
  body.theme-dark .select-bar button { background: #1e293b; }
  body.theme-dark .select-bar button:hover { background: #334155; }
}
