/* 智造云 · 智能制造数字化系统 — 专业企业风格 */
:root {
  --primary: #1a6fd4;
  --primary-dark: #1256a8;
  --primary-light: #e8f2fd;
  --success: #16a34a;
  --success-bg: #e8f8ee;
  --warning: #d97706;
  --warning-bg: #fff5e6;
  --danger: #dc2626;
  --danger-bg: #fdeaea;
  --info: #0891b2;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --border: #e3e9f0;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --side: #101b2d;
  --side-2: #17243a;
  --shadow: 0 2px 12px rgba(15, 40, 80, .06);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }
button, input, select, textarea { font-family: inherit; font-size: inherit; outline: none; }
button { cursor: pointer; }
a { color: var(--primary); }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1e3a6b 0%, transparent 45%),
              radial-gradient(circle at 85% 80%, #0f766e 0%, transparent 40%), #0b1526;
  position: relative; overflow: hidden; }
.login-wrap::before { content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 48px 48px; }
.login-box { width: 430px; background: rgba(255,255,255,.97); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.4); position: relative; z-index: 1; }
.login-brand { background: linear-gradient(135deg, #1a6fd4, #0f766e); padding: 32px 36px 28px; color: #fff; text-align: center; }
.login-brand .logo-mark { margin: 0 auto 14px; width: 56px; height: 56px; font-size: 28px;
  background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.5); }
.login-brand h1 { font-size: 26px; letter-spacing: 3px; font-weight: 600; }
.login-brand p { font-size: 12px; opacity: .85; margin-top: 6px; letter-spacing: .5px; }
.login-form { padding: 30px 36px 24px; }
.login-form label { display: block; font-size: 12px; color: var(--text-2); margin: 14px 0 6px; font-weight: 600; }
.login-form input { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 7px;
  padding: 0 13px; background: #fafbfd; transition: .2s; }
.login-form input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.login-form .btn-primary { margin-top: 22px; height: 44px; font-size: 15px; letter-spacing: 4px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 14px; text-align: center; }
.err { color: var(--danger); font-size: 12px; margin-top: 10px; text-align: center; }
.login-foot { background: #f8fafc; padding: 12px; text-align: center; font-size: 11px; color: var(--text-3); border-top: 1px solid var(--border); }
.logo-mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #1a6fd4, #0f766e);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }

/* ---------- 主布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--side); color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.side-brand { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 18px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.08); background: var(--side-2); }
.side-brand b { color: #fff; font-size: 16px; letter-spacing: 1px; display: block; }
.side-brand small { color: #7d8da5; font-size: 10px; display: block; margin-top: 1px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 10px 0; }
.side-scroll::-webkit-scrollbar { width: 5px; }
.side-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.menu-group { display: flex; align-items: center; gap: 10px; padding: 10px 18px; font-size: 13px; font-weight: 500;
  cursor: pointer; color: #b4c1d4; user-select: none; transition: .15s; }
.menu-group:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-icon { width: 18px; text-align: center; font-size: 15px; color: #6f8bb5; }
.chev { margin-left: auto; font-size: 10px; color: #64748b; }
.menu-children { padding: 2px 0 6px; background: rgba(0,0,0,.16); }
.menu-item { padding: 8px 18px 8px 46px; font-size: 12.5px; color: #94a3b8; cursor: pointer;
  border-left: 3px solid transparent; transition: .15s; }
.menu-item:hover { color: #fff; background: rgba(255,255,255,.04); }
.menu-item.active { color: #fff; background: rgba(26,111,212,.28); border-left-color: #3b9dff; font-weight: 600; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.user-line { font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: #fff; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.crumb { font-size: 14px; color: var(--text-2); }
.crumb b { color: var(--text); }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 4px var(--success-bg); display: inline-block; }
.top-time { font-variant-numeric: tabular-nums; color: var(--text-3); }
.content { padding: 24px 28px 40px; flex: 1; }
.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-title h2 { font-size: 20px; font-weight: 600; letter-spacing: .5px; }
.page-title .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 10px; }

/* ---------- 卡片 / 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; padding-left: 10px;
  border-left: 3px solid var(--primary); }
.panel h4 { font-size: 13px; margin: 14px 0 10px; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-grid .panel { margin-bottom: 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-card::after { content: ''; position: absolute; right: -12px; top: -12px; width: 60px; height: 60px;
  border-radius: 50%; background: var(--primary-light); opacity: .5; }
.kpi-label { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.kpi-card.warn .kpi-value { color: var(--warning); }
.kpi-card.danger .kpi-value { color: var(--danger); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { background: #f7f9fc; color: var(--text-2); font-weight: 600; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f0f3f7; color: var(--text); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f8fbff; }
.tbl .empty, .empty { text-align: center; color: var(--text-3); padding: 26px 12px; }
.empty-big { text-align: center; color: var(--text-3); padding: 60px 20px; font-size: 14px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.gray { background: #f1f5f9; color: #64748b; }
.badge.orange { background: var(--warning-bg); color: var(--warning); }
.badge.red { background: var(--danger-bg); color: var(--danger); }
.badge.blue { background: var(--primary-light); color: var(--primary); }

/* ---------- 表单 / 按钮 ---------- */
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-grid label, .form-row label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea,
.form-row input, .form-row select, .toolbar input, .toolbar select {
  width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 6px; padding: 0 11px;
  background: #fff; transition: .2s; }
.form-grid input:focus, .form-grid select:focus, .form-row input:focus, .form-row select:focus,
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.btn-primary { background: var(--primary); color: #fff; border: none; border-radius: 6px;
  padding: 9px 20px; font-weight: 600; transition: .2s; white-space: nowrap; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 16px; transition: .2s; }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-link { background: none; border: none; color: var(--primary); font-size: 12px; padding: 3px 6px; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.full { width: 100%; }
.small-btn { padding: 5px 10px; font-size: 11px; width: 100%; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { width: 240px; }
.toolbar .spacer { flex: 1; }
.result-box { margin-top: 18px; padding: 16px; background: #f8fbff; border: 1px solid #dbeafe; border-radius: 8px; }
.result-box p { font-size: 13px; margin-bottom: 12px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(10,20,40,.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(3px); }
.modal { background: #fff; border-radius: 12px; width: 640px; max-width: 94vw; max-height: 88vh;
  overflow-y: auto; padding: 24px; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.modal h3 { font-size: 16px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
  padding-top: 16px; border-top: 1px solid var(--border); }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 11px 22px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); z-index: 200; animation: toastIn .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- 图表 ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { min-height: 240px; }
.chart-box svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 11px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ---------- AI 助手 ---------- */
.ai-wrap { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 500px; }
.ai-messages { flex: 1; overflow-y: auto; padding: 8px 4px 16px; }
.ai-msg { display: flex; gap: 10px; margin-bottom: 18px; }
.ai-msg .avatar { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: #fff; }
.ai-msg.user .avatar { background: var(--primary); }
.ai-msg.bot .avatar { background: linear-gradient(135deg, #0f766e, #1a6fd4); }
.ai-msg .bubble { max-width: 72%; padding: 12px 16px; border-radius: 10px; font-size: 13px; white-space: pre-wrap; line-height: 1.7; }
.ai-msg.user .bubble { background: var(--primary); color: #fff; border-top-left-radius: 2px; }
.ai-msg.bot .bubble { background: #f4f7fb; border: 1px solid var(--border); border-top-left-radius: 2px; }
.ai-input { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.ai-input input { flex: 1; height: 42px; border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; }
.ai-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.ai-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ai-quick button { background: #f1f7ff; color: var(--primary); border: 1px solid #d6e6fb;
  border-radius: 16px; padding: 5px 12px; font-size: 11px; }
.ai-quick button:hover { background: var(--primary-light); }

/* ---------- 预警 ---------- */
.alert-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid #f0f3f7; }
.alert-item:last-child { border-bottom: none; }
.alert-icon { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 15px; }
.alert-icon.critical { background: var(--danger-bg); color: var(--danger); }
.alert-icon.warning { background: var(--warning-bg); color: var(--warning); }
.alert-icon.info { background: var(--primary-light); color: var(--primary); }
.alert-body { flex: 1; min-width: 0; }
.alert-body b { font-size: 13px; }
.alert-body p { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* ---------- 开放集成平台 ---------- */
.cap-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
.cap-card { display: flex; gap: 14px; padding: 18px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.cap-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.cap-blue::before { background: #1a6fd4; } .cap-purple::before { background: #8b5cf6; }
.cap-teal::before { background: #0f766e; } .cap-orange::before { background: #f59e0b; }
.cap-icon { width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 22px; color: #fff; }
.cap-blue .cap-icon { background: linear-gradient(135deg, #1a6fd4, #4a9dff); }
.cap-purple .cap-icon { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.cap-teal .cap-icon { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.cap-orange .cap-icon { background: linear-gradient(135deg, #d97706, #fbbf24); }
.cap-body h4 { font-size: 15px; margin-bottom: 6px; }
.cap-body p { font-size: 12px; color: var(--text-2); line-height: 1.7; min-height: 42px; }
.cap-stat { margin-top: 10px; font-size: 11.5px; color: var(--text-3); }
.cap-stat b { color: var(--primary-dark); font-size: 13px; }

.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.agent-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: .2s; }
.agent-card:hover { box-shadow: 0 8px 28px rgba(15,40,80,.12); transform: translateY(-2px); }
.agent-card.disabled { opacity: .6; }
.agent-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.agent-head > div:nth-child(2) { flex: 1; }
.agent-head h4 { font-size: 14px; margin-bottom: 3px; }
.agent-avatar { width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7c3aed, #1a6fd4); }
.agent-desc { font-size: 12px; color: var(--text-2); line-height: 1.7; min-height: 40px; }
.agent-meta { display: flex; gap: 18px; font-size: 11px; color: var(--text-3); margin: 12px 0; }
.agent-meta b { color: var(--text); font-size: 13px; }
.agent-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tool-tag { background: #f1f5f9; color: var(--text-2); padding: 3px 8px; border-radius: 4px; font-size: 10.5px; }
.agent-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 12px; border-top: 1px solid var(--border); }
.kb { font-size: 11px; color: var(--text-3); }
.agent-foot .btn-primary { padding: 7px 14px; font-size: 12px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: #334155; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .cap-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .panel-grid, .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .side-brand div:last-child, .menu-group span:not(.menu-icon), .chev, .menu-children, .side-foot { display: none; }
  .menu-group { justify-content: center; padding: 12px 0; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ============ 九大系统数据闭环 ============ */
.flow-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.flow-kpi { background: #fff; border: 1px solid #e5e9f0; border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.flow-kpi span { color: #7a8699; font-size: 13px; }
.flow-kpi b { font-size: 26px; color: #1f2d3d; }
.flow-kpi b.ok { color: #0f9d6e; }
.flow-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 0; }
.flow-node { position: relative; min-width: 78px; padding: 10px 8px; border-radius: 8px; border: 1px solid #d9e2ee; background: #f7faff; text-align: center; }
.flow-node .fn-step { position: absolute; top: -8px; left: -6px; background: #1a6fd4; color: #fff; font-size: 10px; width: 18px; height: 18px; line-height: 18px; border-radius: 50%; }
.flow-node .fn-sys { font-weight: 700; color: #1f2d3d; font-size: 14px; }
.flow-node .fn-act { font-size: 11px; color: #7a8699; margin-top: 4px; }
.flow-node.sys-c2 { background: #fef3f2; border-color: #fecaca; }
.flow-node.sys-crm { background: #eff6ff; border-color: #bfdbfe; }
.flow-node.sys-erp { background: #f0fdf4; border-color: #bbf7d0; }
.flow-node.sys-plm { background: #faf5ff; border-color: #e9d5ff; }
.flow-node.sys-mes { background: #fffbeb; border-color: #fde68a; }
.flow-node.sys-qms { background: #f0fdfa; border-color: #99f6e4; }
.flow-node.sys-wms { background: #fff7ed; border-color: #fed7aa; }
.flow-node.sys-ems { background: #f5f3ff; border-color: #ddd6fe; }
.flow-node.sys-rcs { background: #ecfeff; border-color: #a5f3fc; }
.flow-node.sys-rm { background: #f7fee7; border-color: #d9f99d; }
.flow-node.sys-prp { background: #fefce8; border-color: #fef08a; }
.flow-arrow { color: #9aa8ba; font-size: 16px; }
.flow-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed #e5e9f0; }
.legend-item { font-size: 12px; color: #7a8699; }
.legend-item b { color: #1f2d3d; margin-right: 3px; }
.flow-form { display: flex; gap: 10px; flex-wrap: wrap; }
.flow-form input { flex: 1; min-width: 140px; padding: 9px 12px; border: 1px solid #d9e2ee; border-radius: 6px; }
.hint { color: #98a2b3; font-size: 12px; margin-top: 10px; }
.trace-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 12px; background: #f7faff; border-radius: 8px; font-size: 13px; color: #5a6b80; }
.trace-head b { color: #1a6fd4; font-size: 15px; }
.badge { padding: 2px 8px; border-radius: 10px; background: #fff7e6; color: #d46b08; font-size: 12px; }
.badge-ok { background: #e8fffb; color: #0f9d6e; }
.trace-summary { display: flex; gap: 28px; padding: 14px 12px; }
.trace-summary div { display: flex; flex-direction: column; gap: 4px; }
.trace-summary span { color: #98a2b3; font-size: 12px; }
.trace-summary b { color: #1f2d3d; font-size: 18px; }
.timeline { padding: 14px 4px 4px; }
.timeline-item { display: flex; gap: 14px; position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: 13px; top: 26px; bottom: 0; width: 2px; background: #e5e9f0; }
.timeline-item:last-child::before { display: none; }
.tl-step { flex: 0 0 28px; height: 28px; line-height: 28px; text-align: center; background: #1a6fd4; color: #fff; border-radius: 50%; font-size: 12px; z-index: 1; }
.tl-body { flex: 1; background: #fff; border: 1px solid #eef1f6; border-radius: 8px; padding: 8px 12px; }
.tl-title { font-size: 14px; color: #1f2d3d; }
.tl-sys { display: inline-block; min-width: 34px; padding: 1px 6px; margin-right: 6px; background: #eff6ff; color: #1a6fd4; border-radius: 4px; font-size: 12px; }
.tl-doc { color: #8b95a5; font-size: 12px; margin-left: 8px; }
.tl-detail { color: #5a6b80; font-size: 13px; margin-top: 4px; }
.tl-time { color: #b0b8c4; font-size: 11px; margin-top: 4px; }
.empty-hint { padding: 40px; text-align: center; color: #a0aab8; }
.btn-mini { padding: 4px 10px; margin-right: 6px; border: 1px solid #d9e2ee; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; color: #1a6fd4; }
.btn-mini:hover { background: #eff6ff; }
