/* ============ 产品经理 ERP 系统 - 全局样式 ============ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0891b2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 230px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  padding: 20px;
}
.login-card {
  width: 420px; max-width: 100%; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 40px 36px;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff;
}
.login-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--gray-900); }
.login-sub { text-align: center; color: var(--gray-500); font-size: 13px; margin: 6px 0 28px; }
.login-tip {
  margin-top: 18px; padding: 10px 14px; background: var(--gray-50);
  border: 1px dashed var(--gray-300); border-radius: 8px;
  font-size: 13px; color: var(--gray-500); text-align: center;
}

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--gray-900); color: #fff;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  display: flex; flex-direction: column; transition: transform .2s;
}
.sidebar-brand {
  padding: 20px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.sidebar-brand .brand-text { font-weight: 700; font-size: 15px; line-height: 1.3; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--gray-400); font-weight: 400; }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-group { margin-bottom: 8px; }
.nav-group-title {
  font-size: 11px; color: var(--gray-500); padding: 8px 10px 4px; letter-spacing: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; color: var(--gray-300); cursor: pointer; font-size: 14px;
  transition: all .15s; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; font-size: 16px; }
.sidebar-user {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 15px;
}
.sidebar-user .uname { font-size: 14px; font-weight: 600; }
.sidebar-user .urole { font-size: 12px; color: var(--gray-400); }
.sidebar-user .logout-btn {
  margin-left: auto; background: none; border: none; color: var(--gray-400);
  font-size: 18px; cursor: pointer; padding: 4px;
}
.sidebar-user .logout-btn:hover { color: #f87171; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 19px; font-weight: 700; color: var(--gray-900); }
.topbar .page-breadcrumb { font-size: 13px; color: var(--gray-500); }
.content { padding: 24px; flex: 1; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ============ 通用组件 ============ */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; color: var(--gray-900); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid transparent; font-size: 14px; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
  color: var(--gray-800); transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  background: var(--gray-50); color: var(--gray-600); text-align: left;
  padding: 11px 12px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:hover { background: var(--gray-50); }
.table .actions { display: flex; gap: 6px; }

/* 标签 / 徽章 */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px;
  font-weight: 600; white-space: nowrap;
}
.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-green { background: var(--success-light); color: var(--success); }
.tag-orange { background: var(--warning-light); color: var(--warning); }
.tag-red { background: var(--danger-light); color: var(--danger); }
.tag-gray { background: var(--gray-100); color: var(--gray-600); }
.tag-cyan { background: #ecfeff; color: var(--info); }
.stock-tag.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; border: 1px solid transparent; }
.stock-tag.clickable:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.12); border-color: var(--primary); }
.stock-tag.clickable::after { content: " ✎"; opacity: 0; transition: opacity .15s; }
.stock-tag.clickable:hover::after { opacity: .8; }

/* 状态条 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.stat-link { cursor: pointer; transition: transform .15s, box-shadow .15s; position: relative; }
.stat-link:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.1); }
.stat-link .stat-arrow {
  margin-left: auto; font-size: 22px; color: var(--gray-300); font-weight: 700;
  transition: color .15s, transform .15s;
}
.stat-link:hover .stat-arrow { color: var(--primary); transform: translateX(3px); }
.stat-card .stat-ico {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-card .stat-num { font-size: 26px; font-weight: 800; color: var(--gray-900); line-height: 1.2; }
.stat-card .stat-label { font-size: 13px; color: var(--gray-500); }

/* 空状态 */
.empty {
  text-align: center; padding: 46px 20px; color: var(--gray-400);
}
.empty .empty-ico { font-size: 46px; margin-bottom: 10px; }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .15s;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column;
  animation: slideUp .18s;
}
.modal-lg { width: 760px; }
.modal-xl { width: 1080px; max-width: 96vw; }
.modal-resizable { resize: both; overflow: auto; min-width: 420px; min-height: 320px; }
.modal-header {
  padding: 16px 22px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header .m-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--gray-400); cursor: pointer; line-height: 1; padding: 2px 6px; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 10px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Toast */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 10px; color: #fff; font-size: 14px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: slideIn .2s; max-width: 360px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Tab */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); margin-bottom: 18px; overflow-x: auto; }
.tab-item {
  padding: 10px 18px; font-size: 14px; font-weight: 500; color: var(--gray-500);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

/* 产品信息条目卡片 */
.info-card {
  border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 14px; background: #fff; position: relative;
}
.info-card .info-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; color: var(--gray-900); display: flex; align-items: center; gap: 8px; }
.info-card .info-title .tag { margin-left: 0; }
.info-card .info-body { font-size: 14px; color: var(--gray-700); }
.info-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 20px; }
.info-kv .kv-item { display: flex; gap: 8px; font-size: 14px; }
.info-kv .kv-key { color: var(--gray-500); flex-shrink: 0; min-width: 90px; }
.info-kv .kv-val { color: var(--gray-800); word-break: break-all; }
.info-card .info-ops { position: absolute; top: 12px; right: 14px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.info-card:hover .info-ops { opacity: 1; }

/* 详情页头部 */
.detail-head {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 20px; display: flex; align-items: flex-start; gap: 16px;
}
.detail-head .d-title { font-size: 22px; font-weight: 800; color: var(--gray-900); }
.detail-head .d-sub { color: var(--gray-500); font-size: 14px; margin-top: 4px; }
.detail-head .d-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.detail-head .d-actions { margin-left: auto; display: flex; gap: 10px; }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-input { width: 240px; }

/* 权限复选框 */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.perm-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--gray-200); border-radius: 8px; font-size: 14px; cursor: pointer;
}
.perm-item:hover { border-color: var(--primary); }
.perm-item input { width: 16px; height: 16px; accent-color: var(--primary); }

/* 加载 */
.loading { text-align: center; padding: 60px; color: var(--gray-400); }
.loading .spin {
  width: 34px; height: 34px; border: 3px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; margin: 0 auto 12px; animation: rotate 0.8s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

/* 响应式 */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .form-row { flex-direction: column; gap: 0; }
  .content { padding: 16px; }
}
@media (max-width: 1100px) {
  .profit-calc-grid { grid-template-columns: 1fr !important; }
}


/* ================= 手机模式（Store.mobile，PC/手机切换） ================= */
.mode-switch { display: inline-flex; gap: 4px; background: var(--gray-100); border-radius: 999px; padding: 3px; }
.mode-switch button {
  border: none; background: transparent; color: var(--gray-500); font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.mode-switch button.on { background: var(--primary); color: #fff; }
/* PC 侧栏：品牌下方独立一行（深色适配，不挤压品牌文字） */
.sidebar-mode { padding: 10px 14px 4px; }
.sidebar-mode .mode-switch { display: flex; width: 100%; background: rgba(255,255,255,.08); }
.sidebar-mode .mode-switch button { flex: 1; color: var(--gray-400); padding: 5px 8px; }
.sidebar-mode .mode-switch button.on { background: #fff; color: var(--gray-900); }
/* 手机顶栏：紧凑小号 */
.mode-switch.m button { font-size: 11.5px; padding: 3px 8px; }

/* 手机壳 */
body.m-mode { overflow-x: hidden; }
.m-shell { min-height: 100vh; background: var(--gray-100); display: flex; flex-direction: column; }
.m-topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--gray-200);
}
.m-brand { display: flex; align-items: center; gap: 8px; font-size: 15px; flex: 1; min-width: 0; }
.m-brand b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-logo { font-size: 20px; }
.m-logout {
  border: none; background: var(--gray-100); color: var(--gray-600); width: 34px; height: 34px;
  border-radius: 10px; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
/* 手机纵向菜单（上下滑动，不用横向滚动） */
.m-nav { padding: 10px 12px 2px; }
.m-nav-title {
  font-size: 11px; color: var(--gray-400); letter-spacing: 1px;
  padding: 8px 4px 2px; font-weight: 600;
}
.m-nav-item {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  background: #fff; border: 1px solid var(--gray-200); border-radius: 12px;
  padding: 11px 14px; margin-bottom: 8px; font-size: 14.5px; font-weight: 600;
  color: var(--gray-700);
}
.m-nav-item .ico { font-size: 17px; width: 22px; text-align: center; }
.m-nav-item .lbl { flex: 1; }
.m-nav-item .arr { color: var(--gray-300); font-size: 18px; font-weight: 400; }
.m-nav-item.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.m-nav-item.on .arr { color: rgba(255,255,255,.7); }
.m-content { flex: 1; padding: 12px; max-width: 860px; width: 100%; margin: 0 auto; }
.m-content .card { border-radius: 14px; }
.m-content .page-title, .m-content h1 { font-size: 18px; }

/* 手机模式下通用表格/弹窗适配 */
body.m-mode .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body.m-mode .table { min-width: 640px; }
body.m-mode .modal-card { width: 94vw !important; max-width: 94vw !important; max-height: 92vh; }
body.m-mode .form-row { flex-direction: column; gap: 0; }
body.m-mode .content { padding: 12px; }

/* 工厂订单筛选/排序工具栏（工厂账号与内部员工共用） */
.fo-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.fo-filters .fo-num { display: inline-flex; gap: 6px; align-items: center; }
/* 手机模式：筛选/排序纵向排列，每项占满整行（配合上下滑动） */
body.m-mode .fo-filters { flex-direction: column; align-items: stretch; gap: 8px; }
body.m-mode .fo-filters > *,
body.m-mode .fo-filters .fo-num > * { width: 100% !important; }
body.m-mode .fo-filters .fo-num { display: flex; flex-direction: row; gap: 6px; }
body.m-mode .fo-filters .fo-num > select:first-child { flex: 1.2; }
body.m-mode .fo-filters .fo-num > select:nth-child(2) { flex: 1; }
body.m-mode .fo-filters .fo-num > input { flex: 0.9; }

/* 工厂订单手机卡片 */
.fo-cards { display: flex; flex-direction: column; gap: 12px; }
.fo-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: 14px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); cursor: pointer;
}
.fo-c-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.fo-c-head b { font-size: 15px; color: var(--gray-700); }
.fo-c-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.fo-c-line { display: flex; font-size: 13.5px; line-height: 1.9; }
.fo-c-k { color: var(--gray-500); width: 72px; flex-shrink: 0; }
.fo-c-qty { display: flex; gap: 14px; background: var(--gray-50); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13.5px; }
.fo-c-qty .m-warn { color: var(--warning); }
.fo-c-qty .m-ok { color: var(--success); }
.fo-c-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--gray-200); }
.fo-c-atts { font-size: 12.5px; color: var(--gray-500); }
.fo-c-btns { display: flex; gap: 6px; }
