/* ============================================================
   机械零配件仓库进销存管理系统 - 样式
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ============ 侧边栏 ============ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar.collapsed { transform: translateX(-220px); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.logo-text h1 { font-size: 16px; color: #fff; font-weight: 600; line-height: 1.2; }
.logo-text span { font-size: 11px; color: #64748b; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}

.nav-icon { font-size: 17px; width: 22px; text-align: center; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 10px 14px;
}

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.06); }

.stock-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.04);
  padding: 10px 12px;
  border-radius: 8px;
}

.stock-status .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22,163,74,.2);
  flex-shrink: 0;
}

.stock-status strong { display: block; font-size: 13px; color: #e2e8f0; }
.stock-status small { font-size: 11px; color: #64748b; }

/* ============ 主区域 ============ */
.main {
  margin-left: 220px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

.main.expanded { margin-left: 0; }

.topbar {
  height: 76px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 20px;
  flex-shrink: 0;
  min-width: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar-left h2 { font-size: 16px; font-weight: 600; white-space: nowrap; color: var(--text); overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.sys-chip { font-size: 12px; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; white-space: nowrap; flex-shrink: 0; }

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

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 4px 0 12px;
  overflow: hidden;
  flex-shrink: 0;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  padding: 8px 4px;
  width: 200px;
  font-size: 13px;
  color: var(--text);
  transition: width .18s ease;
}

.search-box input:focus { width: 260px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; padding-left: 16px; margin-left: 2px; border-left: 1px solid var(--border); }

.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 16px; margin-left: 2px; border-left: 1px solid var(--border); }

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}

.user-info strong { display: block; font-size: 13px; }
.user-info small { font-size: 11px; color: var(--text-muted); }

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

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font);
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 5px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  transition: all .15s;
  line-height: 1;
}

.icon-btn:hover { background: var(--bg); color: var(--text); }

/* 退出登录按钮：放大、带边框、更显眼 */
.logout-btn {
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--danger, #e5484d);
  color: var(--danger, #e5484d);
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
}
.logout-btn:hover {
  background: var(--danger, #e5484d);
  color: #fff;
  border-color: var(--danger, #e5484d);
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-header .sub { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 20px; }

/* ============ 统计卡片 ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-icon.red { background: var(--danger-light); }
.stat-icon.teal { background: var(--info-light); }
.stat-icon.purple { background: #ede9fe; }

.stat-info .stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-info .stat-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.3; }
.stat-info .stat-sub { font-size: 11px; color: var(--text-muted); }

/* ============ 表格 ============ */
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  background: #f8fafc;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* 员工领用表格：加大行高与明细列宽，避免拥挤 */
.req-table td { padding: 16px 14px; }

.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* 徽章 */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }
.badge-teal { background: var(--info-light); color: var(--info); }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* 角色标签 */
.role-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 4px;
}
.role-admin { background: var(--danger-light); color: var(--danger); }
.role-employee { background: var(--primary-light); color: var(--primary-dark); }
.role-superadmin { background: #fae8ff; color: #a21caf; }
.role-custom { background: #ede9fe; color: #6d28d9; }
.role-operator { background: var(--success-light); color: var(--success); }
.role-viewer { background: var(--warning-light); color: var(--warning); }
.role-purchaser { background: #fff7ed; color: #c2410c; }
.role-warehouse { background: #ecfeff; color: #0e7490; }
.role-accountant { background: #f5f3ff; color: #6d28d9; }
.role-sales { background: #fef2f2; color: #b91c1c; }
.role-superadmin { background: #fef3c7; color: #b45309; }

/* 单位详情信息栅格 */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 24px;
  padding: 6px 4px;
}
.info-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.info-value {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

/* 面包屑 */
.breadcrumb { font-size: 13px; color: var(--text-secondary); }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* 操作按钮 */
.row-actions { display: flex; gap: 4px; }
.row-actions .icon-btn { font-size: 14px; padding: 4px 6px; }
.row-actions .icon-btn.edit:hover { color: var(--primary); background: var(--primary-light); }
.row-actions .icon-btn.del:hover { color: var(--danger); background: var(--danger-light); }
.row-actions .icon-btn.view:hover { color: var(--info); background: var(--info-light); }

/* ============ 表单 ============ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.form-grid .full { grid-column: 1 / -1; }

/* 采购/销售单：选中供应商/客户后展示的地址与链接 */
.partner-info {
  display: none;
  margin-top: 10px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  color: #475569;
  line-height: 1.7;
}
.partner-info .pi-title { font-weight: 600; color: #1e293b; margin-bottom: 2px; }
.partner-info .pi-label { color: #94a3b8; margin-right: 6px; }
.partner-info a { color: #2563eb; text-decoration: underline; word-break: break-all; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group label .req { color: var(--danger); }

.form-group input, .form-group select, .form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-group input:disabled, .form-group select:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-hint { font-size: 11.5px; color: var(--text-muted); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* 单据明细行 */
.order-items { margin: 6px 0 10px; }

.order-item-row {
  display: grid;
  grid-template-columns: 2.5fr 1.2fr 1fr 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.order-item-row select, .order-item-row input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}

.order-item-row select:focus, .order-item-row input:focus { border-color: var(--primary); }

/* 明细行下拉中的「新增零件…」选项高亮 */
.order-item-row select option.opt-add-product {
  color: var(--primary, #2563eb);
  font-weight: 600;
}

/* 可搜索组合框（零件 / 类别 共用同一套外观与交互） */
.product-combobox,
.category-combobox {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 0;
}
.product-combobox .product-search-input,
.category-combobox .category-search-input {
  width: 100%;
  padding-right: 28px;
  cursor: text;
}
.product-combobox::after,
.category-combobox::after {
  content: '▾';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 12px;
}
.product-combobox.open::after,
.category-combobox.open::after { transform: translateY(-50%) rotate(180deg); }
.product-dropdown,
.category-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 100;
  display: none;
}
.product-combobox.open .product-dropdown,
.category-combobox.open .category-dropdown { display: block; }
.product-options,
.category-options {
  list-style: none;
  margin: 0;
  padding: 4px;
}
.product-option,
.category-option {
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-option:hover,
.product-option.active,
.category-option:hover,
.category-option.active {
  background: var(--primary-light);
  color: var(--primary);
}
.product-option-add,
.category-option-add {
  color: var(--primary);
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}
.product-empty,
.category-empty {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
/* 筛选栏中的类别组合框：固定宽度，与其它筛选项对齐 */
.filter-bar .category-combobox { width: 210px; }

/* 规格型号 / 角色 / 租户组合框：复用类别组合框样式 */
.spec-combobox,
.role-combobox,
.tenant-combobox { position: relative; display: inline-block; width: 100%; min-width: 0; }
.product-combobox .product-search-input,
.category-combobox .category-search-input,
.spec-combobox .spec-search-input,
.role-combobox .role-search-input,
.tenant-combobox .tenant-search-input {
  width: 100%;
  padding-right: 28px;
  cursor: text;
}
.product-combobox::after,
.category-combobox::after,
.spec-combobox::after,
.role-combobox::after,
.tenant-combobox::after {
  content: '▾';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 12px;
}
.product-combobox.open::after,
.category-combobox.open::after,
.spec-combobox.open::after,
.role-combobox.open::after,
.tenant-combobox.open::after { transform: translateY(-50%) rotate(180deg); }
.product-dropdown,
.category-dropdown,
.spec-dropdown,
.role-dropdown,
.tenant-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 100;
  display: none;
}
.product-combobox.open .product-dropdown,
.category-combobox.open .category-dropdown,
.spec-combobox.open .spec-dropdown,
.role-combobox.open .role-dropdown,
.tenant-combobox.open .tenant-dropdown { display: block; }
.product-options,
.category-options,
.spec-options,
.role-options,
.tenant-options {
  list-style: none;
  margin: 0;
  padding: 4px;
}
.product-option,
.category-option,
.spec-option,
.role-option,
.tenant-option {
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-option:hover,
.product-option.active,
.category-option:hover,
.category-option.active,
.spec-option:hover,
.spec-option.active,
.role-option:hover,
.role-option.active,
.tenant-option:hover,
.tenant-option.active {
  background: var(--primary-light);
  color: var(--primary);
}
.product-empty,
.category-empty,
.spec-empty,
.role-empty,
.tenant-empty {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* ============ 筛选栏 ============ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.filter-bar input, .filter-bar select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  outline: none;
  background: #fff;
  font-family: var(--font);
}

.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }

/* 批量操作工具条 */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--primary-light, #eff6ff);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.batch-bar .batch-count { font-weight: 600; color: var(--primary, #2563eb); }

/* 列表勾选列 */
.data-table th.col-check,
.data-table td.col-check {
  width: 38px;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}
.data-table th.col-check input,
.data-table td.col-check input { cursor: pointer; }

/* ============ 模态框 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  z-index: 200;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: all .2s;
}

.modal-overlay.show { opacity: 1; visibility: visible; }

.modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 620px;
  max-width: 100%;
  animation: modalIn .2s ease;
  margin-bottom: 40px;
}

.modal-lg { width: 860px; }
.modal-sm { width: 420px; }

@keyframes modalIn {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 22px; max-height: calc(100vh - 180px); overflow-y: auto; }

/* ============ Toast 提示 ============ */
.toast-container {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn .25s ease;
  min-width: 200px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ 仪表盘布局 ============ */
.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-box { height: 300px; position: relative; }

.mini-chart-box { height: 240px; position: relative; }

/* 简易柱状图/环形图 */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 230px;
  padding: 10px 6px 0;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar-col .bar-val { font-size: 11px; color: var(--text-secondary); font-weight: 600; }

.bar-col .bar {
  width: 60%;
  max-width: 44px;
  border-radius: 5px 5px 0 0;
  background: var(--primary);
  min-height: 2px;
  transition: height .4s ease;
  position: relative;
}

.bar-col:nth-child(2n) .bar { background: var(--info); }
.bar-col:nth-child(3n) .bar { background: #7c3aed; }

.bar-col .bar-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  text-align: center;
  max-height: 50px;
  overflow: hidden;
}

/* 环形图 */
.donut-wrap { display: flex; align-items: center; gap: 20px; justify-content: center; height: 220px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.donut-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.donut-legend .legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .legend-val { font-weight: 600; color: var(--text); margin-left: auto; padding-left: 16px; }

/* ============ 低库存/待办列表 ============ */
.alert-list { list-style: none; }
.alert-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.alert-list li:last-child { border-bottom: none; }
.alert-list li:hover { background: #f8fafc; }
.alert-list .alert-name { font-weight: 500; }
.alert-list .alert-meta { font-size: 12px; color: var(--text-muted); }
.alert-list .alert-action { color: var(--primary); cursor: pointer; font-size: 12.5px; }
.alert-list .alert-action:hover { text-decoration: underline; }

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 44px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* ============ 详情视图 ============ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.detail-item { background: #f8fafc; border-radius: 8px; padding: 12px 14px; }
.detail-item .d-label { font-size: 11.5px; color: var(--text-muted); }
.detail-item .d-value { font-size: 14px; font-weight: 500; margin-top: 2px; }

/* ============ 加载动画 ============ */
.loading-screen {
  position: fixed;
  inset: 0;
  background: rgba(241, 245, 249, .8);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  z-index: 90;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 分段统计 Tab ============ */
.seg-tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 8px; }
.seg-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font);
}
.seg-tab.active { background: #fff; color: var(--primary); font-weight: 500; box-shadow: var(--shadow); }

/* ============ 进度条 ============ */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.progress .progress-bar { height: 100%; border-radius: 4px; background: var(--primary); transition: width .3s; }
.progress .progress-bar.warn { background: var(--warning); }
.progress .progress-bar.danger { background: var(--danger); }
.progress-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ============ 打印样式 ============ */
@media print {
  .sidebar, .topbar, .filter-bar, .row-actions, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; overflow: visible; }
  body { overflow: visible; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ============ 移动端底部导航 ============ */
.bottom-nav { display: none; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-220px); }
  .main { margin-left: 0; }
  .sidebar.mobile-open { transform: translateX(0); }
  /* 中屏：隐藏较长系统名，避免顶栏拥挤 */
  .sys-chip { display: none; }
  .topbar-left h2 { max-width: 160px; }
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-box input { width: 120px; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; }

  /* 手机端：隐藏侧边栏抽屉，改用底部标签栏 */
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: none; }
  .search-box { display: none; }
  .topbar { padding: 0 12px; }
  .topbar-right { gap: 8px; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 12px; }
  .user-info { display: none; }
  .content { padding-bottom: 78px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--sidebar-bg);
    z-index: 120;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -2px 12px rgba(15,23,42,.18);
  }
  .bottom-nav-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 6px 4px;
    margin: 0;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 10px;
    gap: 2px;
    width: auto;
  }
  .bottom-nav-item .nav-icon { font-size: 19px; width: auto; }
  .bottom-nav-item .nav-label { font-size: 11px; line-height: 1.1; }
  .bottom-nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
  }
  /* 手机端对话框更友好 */
  .modal { width: 100%; margin: 0 10px; }
  .order-item-row { grid-template-columns: 1fr 1fr; }
  .order-item-row select, .order-item-row input { width: 100%; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; }

/* 金额显示 */
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.money-positive { color: var(--danger); }
.money-negative { color: var(--success); }

/* 数字单元格 */
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* 表格操作列 */
.actions-col { text-align: right; white-space: nowrap; }

/* 排序指示 */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }
.sort-arrow { font-size: 10px; margin-left: 3px; }

/* ============ 登录页 ============ */
.login-view {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  margin: auto;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
}
.login-card h1 {
  font-size: 22px;
  color: var(--text);
  margin-bottom: 6px;
}
.login-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}
.login-form { text-align: left; }
.login-field { margin-bottom: 18px; }
.login-field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .2s;
  outline: none;
}
.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  transition: opacity .2s;
}
.login-btn:hover { opacity: .9; }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
.login-hint {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.8;
}
.login-hint code {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary);
}
.login-back { margin-top: 8px; }
.login-back a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
}
.login-back a:hover { color: var(--primary); }

/* ============ 入口选择页 ============ */
.portal-selection {
  width: 100%;
  max-width: 1000px;
  text-align: center;
  margin: auto;
}
.portal-header { margin-bottom: 40px; }
.portal-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  backdrop-filter: blur(10px);
}
.portal-header h1 {
  color: #fff;
  font-size: 28px;
  margin-bottom: 8px;
}
.portal-header p {
  color: rgba(255,255,255,.6);
  font-size: 15px;
}
.portal-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}
.portal-card {
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 36px 24px;
  text-decoration: none;
  color: #fff;
  transition: all .3s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.portal-card:hover {
  background: rgba(255,255,255,.15);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.portal-card-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 18px;
}
.portal-admin .portal-card-icon { background: rgba(220,38,38,.25); }
.portal-operator .portal-card-icon { background: rgba(37,99,235,.25); }
.portal-viewer .portal-card-icon { background: rgba(5,150,105,.25); }
.portal-purchases .portal-card-icon { background: rgba(234,88,12,.25); }
.portal-sales .portal-card-icon { background: rgba(124,58,237,.25); }
.portal-requisitions .portal-card-icon { background: rgba(13,148,136,.25); }
.portal-suppliers .portal-card-icon { background: rgba(79,70,229,.25); }
.portal-customers .portal-card-icon { background: rgba(219,39,119,.25); }
.portal-section-title {
  color: rgba(255,255,255,.5);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.portal-cards-modules {
  grid-template-columns: repeat(5, 1fr);
}
.portal-cards-modules .portal-card {
  padding: 28px 16px;
}
.portal-cards-modules .portal-card h2 {
  font-size: 16px;
}
.portal-cards-modules .portal-card-icon {
  width: 52px;
  height: 52px;
  font-size: 26px;
}
.portal-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}
.portal-card p {
  font-size: 13px;
  color: rgba(255,255,255,.55);
  margin-bottom: 20px;
  line-height: 1.6;
}
.portal-card-btn {
  font-size: 14px;
  color: rgba(255,255,255,.8);
  padding: 8px 20px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  transition: all .2s;
}
.portal-card:hover .portal-card-btn {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.portal-footer {
  color: rgba(255,255,255,.3);
  font-size: 12px;
}
@media (max-width: 768px) {
  .portal-cards { grid-template-columns: 1fr; }
  .portal-cards-modules { grid-template-columns: repeat(2, 1fr); }
}
