/* ===== 阀门工单管理系统 - 公共样式 ===== */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #34a853;
  --warning: #f9ab00;
  --danger: #ea4335;
  --info: #4285f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-disabled: #bdc1c6;
  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --border: #dadce0;
  --border-light: #e8eaed;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 4px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.main-header {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.main-header h1 { font-size: 18px; font-weight: 600; }
.main-header .header-right { display: flex; align-items: center; gap: 16px; }
.main-header .user-info {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 12px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.main-header .user-info:hover { background: var(--bg-page); }
.main-header .user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.main-content { flex: 1; padding: 24px; }

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== 产品导入 ===== */
.btn-import { background: #4a8bf5; color: #fff; }
.btn-import:hover { background: #3a7be8; }

/* ===== Button ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d33b2c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #e09e00; }
.btn-default { background: #fff; color: var(--text-primary); border: 1px solid var(--border); }
.btn-default:hover { background: var(--bg-page); border-color: var(--text-disabled); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-label .required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}
.form-input:disabled, .form-select:disabled { background: var(--bg-page); color: var(--text-disabled); }
/* 全站：去除数字输入框的上下步进器（避免误点加减数量） */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-row > .form-group { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-disabled); margin-top: 4px; }

/* ===== Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  /* 表头统一居中 */
  text-align: center;
  padding: 12px 16px;
  background: var(--bg-page);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  /* 数据统一左对齐；缩窄列宽时省略号截断，不换行 */
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tbody tr:hover { background: #fafbfc; }
.data-table .actions { display: flex; gap: 8px; white-space: nowrap; align-items: center; }
.data-table .empty-row td { text-align: center; color: var(--text-disabled); padding: 40px 0; }

/* ===== 列宽拖拽（ColResize 引擎注入）===== */
/* 表格横向滚动容器（列宽拖宽后不撑破卡片） */
.table-scroll { overflow-x: auto; }
/* 一旦启用列宽拖拽，即固定表格布局，使列宽像素精确生效 */
table.data-table.col-resizable { table-layout: fixed; }
.data-table th { position: relative; }
.col-resizer {
  position: absolute; top: 0; right: 0;
  width: 0.5px; height: 100%;
  cursor: col-resize; user-select: none; z-index: 2;
  background: #80868b; opacity: .85;      /* 默认可见的细线手柄（比表头底色明显加深）*/
}
.col-resizer::before { content: ''; position: absolute; top: 0; left: -3px; right: -3px; height: 100%; } /* 透明热区：0.5px 细线也好拖 */
.col-resizer:hover { background: var(--primary); opacity: 1; }
/* 拖拽过程中：整页锁定光标与选区，避免选中文字 */
body.col-resizing { cursor: col-resize !important; user-select: none !important; }
body.col-resizing * { user-select: none !important; cursor: col-resize !important; }
body.col-resizing .col-resizer { background: var(--primary); opacity: 1; }

/* ===== Badge / Tag ===== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}
.tag-primary { background: var(--primary-light); color: var(--primary); }
.tag-success { background: #e6f4ea; color: var(--success); }
.tag-warning { background: #fef7e0; color: var(--warning); }
.tag-danger { background: #fce8e6; color: var(--danger); }
.tag-default { background: #f1f3f4; color: var(--text-secondary); }
.tag-info { background: #e0f0ff; color: var(--info); }
.tag-teal { background: #e0f2f1; color: #00897b; }

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.filter-bar .search-box input { padding-left: 36px; }
.filter-bar .search-box .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-disabled); font-size: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.filter-bar .search-box .search-icon::before {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bdc1c6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bdc1c6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center;
  -webkit-mask-size: contain;
  mask-size: contain;
  background: var(--text-disabled);
}
/* 左筛选卡：带标签的纵向字段 + 操作按钮 */
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.filter-actions { display: flex; gap: 10px; margin-top: 4px; }
.filter-actions .btn { flex: 1; }
/* 筛选栏字段/输入框/选框统一宽度 208px（全局规范，新增页面同样遵循） */
.filter-bar > .filter-field { width: 208px; flex: none; }
.filter-bar > .form-input, .filter-bar > .form-select { width: 208px; flex: none; }
/* 左栏内字段纵向铺满、日期框与输入框对齐 */
.filter-aside .filter-field { width: 100%; }
.filter-aside .filter-field .form-input,
.filter-aside .filter-field .form-select { width: 100%; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 90%; max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal.modal-lg { max-width: 800px; }
.modal.modal-sm { max-width: 400px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-header .modal-close { font-size: 22px; cursor: pointer; color: var(--text-disabled); line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== 按钮内 SVG 图标（与文字对齐） ===== */
.btn svg { width: 15px; height: 15px; vertical-align: -2.5px; margin-right: 4px; }
.btn.btn-sm svg { width: 13px; height: 13px; vertical-align: -2px; }

/* ===== 商标缩略图 & 大图查看 ===== */
.tm-thumb {
  height: 22px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  vertical-align: middle;
  margin-left: 6px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: #fff;
  cursor: zoom-in;
}
.tm-btn { padding: 3px 8px; font-size: 12px; }
.img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.img-viewer.show { display: flex; }
.img-viewer img {
  max-width: 92%;
  max-height: 92%;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  background: #fff;
}

/* ===== Stats Card (Dashboard) ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.stats-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-card .stats-label { font-size: 13px; color: var(--text-secondary); }
.stats-card .stats-value { font-size: 28px; font-weight: 700; }
.stats-card .stats-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

/* ===== Pagination ===== */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; align-items: center; }
.pagination .page-info { font-size: 13px; color: var(--text-secondary); margin-right: 12px; }
.pagination .page-btn {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer; font-size: 13px;
}
.pagination .page-btn:hover { background: var(--bg-page); }
.pagination .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* 页码跳转（2026-10-09 全局分页统一） */
.pagination .page-jump { margin-left: 12px; font-size: 13px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 4px; }
.pagination .page-jump-input {
  width: 52px; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; text-align: center; background: #fff;
}
.pagination .page-jump-input:focus { outline: none; border-color: var(--primary); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; border-radius: var(--radius-sm);
  font-size: 14px; z-index: 999; opacity: 0; transition: opacity 0.3s;
  box-shadow: var(--shadow-hover);
}
.toast.show { opacity: 1; }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* ===== Misc ===== */
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }

/* =====================================================================
   方案 B 布局：菜单上移顶部（悬浮下拉）+ 多标签外壳 + 左筛选卡
   —— 与 plan-execution-demo.html 保持一致
   ===================================================================== */

/* body.shell：外壳无滚动，内容在 iframe 内滚动 */
body.shell { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }

/* 顶部栏左侧：品牌 + 一级菜单 */
.main-header .header-left { display: flex; align-items: center; gap: 24px; min-width: 0; flex: 1; }
.main-header .brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.main-header .brand svg { width: 22px; height: 22px; }
.main-header .logout-txt { color: var(--text-disabled); font-size: 12px; }

/* 一级菜单 */
.topnav { display: flex; align-items: center; gap: 2px; height: 60px; }
.topnav-group { position: relative; height: 100%; display: flex; align-items: center; }
.topnav-group > .topnav-link {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  color: var(--text-primary); cursor: pointer; white-space: nowrap; transition: all .15s;
}
.topnav-group > .topnav-link .caret { font-size: 9px; color: var(--text-disabled); transition: transform .2s; }
.topnav-group:hover > .topnav-link { background: var(--primary-light); color: var(--primary); }
.topnav-group:hover > .topnav-link .caret { transform: rotate(180deg); color: var(--primary); }
.topnav-group.active > .topnav-link { color: var(--primary); font-weight: 600; }

/* 悬浮下拉子菜单 */
.dropdown {
  position: absolute; top: 54px; left: 0; min-width: 210px;
  background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius);
  box-shadow: var(--shadow-hover); padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  z-index: 120;
}
.dropdown::before { content: ''; position: absolute; top: -10px; left: 0; right: 0; height: 10px; } /* 防闪断透明区 */
.topnav-group:hover .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown a {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 14px; white-space: nowrap; transition: all .12s;
}
.dropdown a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.dropdown a.active { background: var(--primary); color: #fff; font-weight: 600; }
.dropdown a .nav-icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.dropdown a .nav-icon svg { width: 18px; height: 18px; color: var(--primary); }
.dropdown a.active .nav-icon svg { color: #fff; }

/* 多标签外壳 */
.shell-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tab-bar {
  display: flex; align-items: flex-end; gap: 4px; padding: 8px 16px 0;
  background: var(--bg-page); border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
}
.tab-bar:empty { display: none; }
.tab-bar::-webkit-scrollbar { height: 4px; }
.tab-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: transparent;
  border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
  font-size: 13px; color: var(--text-secondary); cursor: pointer; white-space: nowrap;
  user-select: none; max-width: 200px; transition: all .15s; position: relative; top: 1px;
}
.tab-item:hover { color: var(--primary); background: var(--primary-light); }
.tab-item.active { background: #fff; border-color: var(--border); border-bottom-color: #fff; color: var(--primary); font-weight: 600; }
.tab-item .tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab-close { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; font-size: 15px; line-height: 1; color: var(--text-disabled); }
.tab-close:hover { background: var(--danger); color: #fff; }
.tab-stage { flex: 1; position: relative; overflow: hidden; background: var(--bg-page); }
.tab-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: none; background: var(--bg-page); }
.tab-frame.active { display: block; }

/* iframe 子页：内容区铺满，内边距略收 */
html[data-in-frame] body { background: var(--bg-page); }
html[data-in-frame] .main-content { padding: 16px; }

/* 左筛选卡 + 右主列（原侧栏位置放筛选区） */
.main-content.has-aside { display: flex; gap: 16px; align-items: flex-start; }
.main-content.has-aside .filter-aside { width: 248px; flex-shrink: 0; position: sticky; top: 16px; }
.main-content.has-aside .main-col { flex: 1; min-width: 0; }
.filter-aside .form-group { margin-bottom: 14px; }
/* 筛选控件在窄栏内纵向排布 */
.filter-aside .filter-bar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 0; }
.filter-aside .filter-bar > * { width: 100% !important; }
.filter-aside .filter-bar .search-box { min-width: 0; flex: none; }

/* 筛选卡头：标题与说明文字换行（左栏较窄，避免与 H2 挤在一行） */
.card-header-stack { flex-direction: column; align-items: flex-start; gap: 6px; }
.card-header-stack .card-header-hint { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
/* 左筛选卡内的表头统一纵向排列，说明文字可换行 */
.filter-aside .card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
.filter-aside .card-header > span { font-size: 13px; line-height: 1.5; white-space: normal; }

/* ===== 打印机选择弹窗（2026-10-14 针式三联纸打印支持）===== */
.printer-pick-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.printer-pick { width: 420px; max-width: calc(100vw - 32px); background: #fff; border-radius: 8px; padding: 20px 22px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.printer-pick h3 { font-size: 16px; margin: 0 0 4px; }
.printer-pick .sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }
.printer-pick .opt { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; cursor: pointer; }
.printer-pick .opt:hover { border-color: var(--primary); }
.printer-pick .opt.sel { border-color: var(--primary); background: var(--primary-light); }
.printer-pick .opt .radio { width: 14px; height: 14px; border: 2px solid var(--border); border-radius: 50%; flex: none; }
.printer-pick .opt.sel .radio { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 2px #fff; }
.printer-pick .opt .t { font-size: 14px; font-weight: 600; }
.printer-pick .opt .d { font-size: 12px; color: var(--text-secondary); margin-left: auto; }
.printer-pick .remember { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); margin: 10px 0 14px; cursor: pointer; user-select: none; }
.printer-pick .btns { display: flex; justify-content: flex-end; gap: 10px; }
