:root {
  --primary: #185FA5;
  --primary-light: #E6F1FB;
  --primary-dark: #0C447C;
  --success: #3B6D11;
  --success-light: #EAF3DE;
  --danger: #A32D2D;
  --danger-light: #FCEBEB;
  --warning: #854F0B;
  --warning-light: #FAEEDA;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --bg: #f5f7fa;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --sidebar-w: 220px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== 登录页 ===== */
#login-page { display: none; position: fixed; inset: 0; background: linear-gradient(135deg, #0C447C 0%, #185FA5 60%, #378ADD 100%); align-items: center; justify-content: center; }
#login-page.show { display: flex; }
.login-box { width: 380px; background: #fff; border-radius: 14px; padding: 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo .icon { width: 52px; height: 52px; border-radius: 12px; background: var(--primary); color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-weight: 600; }
.login-logo .logo { display: block; width: 240px; max-height: 80px; margin: 0 auto 14px; object-fit: contain; }
.login-logo h1 { font-size: 20px; font-weight: 600; }
.login-logo p { color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* ===== 布局 ===== */
#app { display: none; min-height: 100vh; }
#app.show { display: block; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: #101828; color: #cbd5e1; z-index: 50; display: flex; flex-direction: column; }
.sidebar .brand { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand .brand-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sidebar .brand .logo { width: 180px; height: auto; max-height: 50px; flex-shrink: 0; object-fit: contain; }
.sidebar .brand .icon { width: 30px; height: 30px; border-radius: 7px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.sidebar .brand b { color: #fff; font-size: 14px; }
.sidebar nav { flex: 1; padding: 8px 0 12px; overflow-y: auto; }
.sidebar nav .menu-group { margin-bottom: 4px; }
.sidebar nav .menu-title { padding: 14px 20px 6px; font-size: 11px; color: #5b6b83; letter-spacing: 1px; user-select: none; }
.sidebar nav .menu-group.group-active .menu-title { color: #7ea6d9; }
.sidebar nav .menu-group:first-child .menu-title { padding-top: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #94a3b8; font-size: 13.5px; cursor: pointer; border-left: 3px solid transparent; transition: all .15s; }
.sidebar nav a:hover { color: #e2e8f0; background: rgba(255,255,255,.04); }
.sidebar nav a.active { color: #fff; background: rgba(56,132,255,.14); border-left-color: #3b82f6; }
.sidebar nav a .ico { width: 18px; text-align: center; font-size: 15px; }
.sidebar .user { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.sidebar .user b { color: #e2e8f0; display: block; margin-bottom: 6px; }
.sidebar .user a { color: #94a3b8; margin-right: 12px; cursor: pointer; }
.sidebar .user a:hover { color: #fff; }

.main { margin-left: var(--sidebar-w); padding: 20px 24px 60px; }
.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-title h2 { font-size: 18px; font-weight: 600; }
.page-title .sub { color: var(--text-2); font-size: 12.5px; margin-top: 3px; }

/* ===== 卡片 ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card .card-h { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.card .card-b { padding: 16px 18px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .label { color: var(--text-2); font-size: 12.5px; margin-top: 4px; }
.stat-card.green .num { color: var(--success); }
.stat-card.orange .num { color: var(--warning); }
.stat-card.red .num { color: var(--danger); }

/* ===== 表格 ===== */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px 12px; background: #f8fafc; color: var(--text-2); font-weight: 500; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tr:hover td { background: #fafbfc; }
.tbl .ops { white-space: nowrap; }
.tbl .ops button { margin-right: 4px; }

/* ===== 按钮 ===== */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--border); background: #fff; font-size: 13px; color: var(--text); transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.success:hover { opacity: .9; }
.btn.danger { color: var(--danger); border-color: #f3c1c1; }
.btn.danger:hover { background: var(--danger-light); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 表单 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; background: #fff; color: var(--text); outline: none; transition: border-color .15s; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-item textarea { resize: vertical; min-height: 60px; font-family: Consolas, Menlo, monospace; }
.form-item .hint { font-size: 11.5px; color: var(--text-2); margin-top: 4px; }

/* ===== 弹窗 ===== */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 980px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { max-width: 1000px; }
.modal .modal-h { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.modal .modal-h .x { cursor: pointer; color: var(--text-2); font-size: 18px; background: none; border: none; }
.modal .modal-b { padding: 20px; }
.modal .modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== 标签 ===== */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.tag.green { background: var(--success-light); color: var(--success); }
.tag.red { background: var(--danger-light); color: var(--danger); }
.tag.blue { background: var(--primary-light); color: var(--primary); }
.tag.gray { background: #f1f5f9; color: var(--text-2); }
.tag.orange { background: var(--warning-light); color: var(--warning); }

/* ===== 工具条 ===== */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 7px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; outline: none; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar .spacer { flex: 1; }

/* ===== 分页 ===== */
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 4px; font-size: 12.5px; color: var(--text-2); }
.pager button { padding: 4px 10px; border: 1px solid var(--border); background: #fff; border-radius: 6px; font-size: 12px; }
.pager button:disabled { opacity: .4; }

/* ===== Toast ===== */
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast-item { background: #111827; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fadeIn .2s; max-width: 480px; }
.toast-item.success { background: var(--success); }
.toast-item.error { background: var(--danger); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ===== 图表 ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding: 8px 4px 0; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-chart .bar .v { font-size: 11px; color: var(--text-2); }
.bar-chart .bar .h { width: 100%; border-radius: 0; min-height: 2px; transition: height .3s; }
.bar-chart .bar .d { font-size: 11px; color: var(--text-2); }
.bar-chart .bar .stack { width: 70%; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 4px 4px 0 0; overflow: hidden; }
.bar-chart .bar .seg-calls { background: #185FA5; }
.bar-chart .bar .seg-tasks { background: #F6A609; }
.bar-chart .bar .seg-flows { background: #0F6E56; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.oa-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.oa-check { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; cursor: pointer; }
.oa-check input { margin: 0; }
.oa-where-row select, .oa-where-row input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; background: var(--card); color: var(--text); }
.oa-help-block { margin-bottom: 16px; }
.oa-help-pre { background: #0d1117; color: #e6edf3; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; line-height: 1.7; }

/* ===== 字段编辑 ===== */
.field-row { display: grid; grid-template-columns: 70px 130px 120px 90px 70px 110px 130px 1fr 60px; gap: 6px; align-items: center; margin-bottom: 6px; }
.field-row.head { font-size: 12px; color: var(--text-2); }
.field-row input, .field-row select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; outline: none; }
.field-row .del { color: var(--danger); background: none; border: none; font-size: 16px; cursor: pointer; }

/* ===== 响应 ===== */
.resp-box { background: #0f172a; color: #d1fae5; border-radius: 8px; padding: 14px; font-family: Consolas, Menlo, monospace; font-size: 12.5px; overflow-x: auto; max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
.resp-box.err { color: #fecaca; }

/* 空状态 */
.empty { text-align: center; color: var(--text-2); padding: 40px 0; font-size: 13px; }

/* ===== 任务流画布卡片式节点 ===== */
.lf-html-node { background: transparent !important; border: none !important; box-shadow: none !important; }
.flow-card { width: 220px; height: 56px; background: #ffffff; border: 1.5px solid #185FA5 !important; border-radius: 10px; display: flex; align-items: center; padding: 0; outline: 1.5px solid #185FA5; outline-offset: -1.5px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); box-sizing: border-box; position: relative; font-family: -apple-system, "PingFang SC", sans-serif; overflow: visible; transition: box-shadow .15s; }
.flow-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.14); }
.flow-card.selected { border-color: #1a73e8 !important; box-shadow: 0 0 0 3px rgba(26,115,232,0.30), 0 4px 14px rgba(26,115,232,0.15) !important; }
.flow-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #ffffff; font-size: 16px; margin-left: 12px; flex-shrink: 0; }
.flow-text { flex: 1; min-width: 0; padding: 0 8px 0 10px; overflow: hidden; }
.flow-title { font-size: 13px; font-weight: 600; color: #1a1a1a; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-sub { font-size: 11px; color: #888; line-height: 16px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-actions { padding: 0 10px 0 4px; color: #bbb; font-size: 13px; cursor: pointer; user-select: none; }
.flow-actions:hover { color: #888; }

/* 选中时浮动操作栏 */
.fc-float-bar { display: none; position: absolute; right: 6px; top: -34px; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 2px 4px; box-shadow: 0 2px 10px rgba(0,0,0,0.12); z-index: 30; gap: 2px; }
.flow-card.selected .fc-float-bar { display: flex; }
.fcfb-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; font-size: 15px; color: #666; transition: background .12s, color .12s; }
.fcfb-btn:hover { background: #fee; color: #d32f2f; }

/* 循环容器虚线框 */
.loop-box { position: absolute; border: 1.5px dashed #993556; border-radius: 12px; pointer-events: none; z-index: 0; background: rgba(153,53,86,0.03); }

/* 自绘连线端点: hover/选中时显示(大尺寸 + 蓝色边框 + 阴影, 容易拖) */
.fc-port { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #ffffff; border: 2.5px solid #1a73e8; cursor: crosshair; z-index: 10; box-sizing: border-box; box-shadow: 0 2px 4px rgba(0,0,0,0.18); opacity: 0; transition: opacity .12s, transform .12s, background .12s, border-color .12s, box-shadow .12s; pointer-events: none; }
.flow-card:hover .fc-port, .flow-card.selected .fc-port { opacity: 1; pointer-events: auto; }
.fc-port:hover, .fc-port:active { transform: scale(1.5); background: #1a73e8; border-color: #1a73e8; box-shadow: 0 3px 8px rgba(26,115,232,0.45); }
.fc-port-l { left: -9px; top: 50%; margin-top: -6px; }
.fc-port-r { right: -9px; top: 50%; margin-top: -6px; }
.fc-port-t { top: -9px; left: 50%; margin-left: -6px; }
.fc-port-b { bottom: -9px; left: 50%; margin-left: -6px; }

/* 彻底隐藏 LogicFlow 1.x 默认 anchor 视觉(避免卡片边缘出现"凹槽"端口) */
.lf-anchor, .lf-anchor > * { display: none !important; }
.lf-node-anchor, .lf-node-anchor-hover { display: none !important; }
/* 隐藏LogicFlow 1.x polyline edge的默认text和编辑手柄 */
.lf-edge-append, .lf-edge-append * { display: none !important; }
.lf-polyline-append-ns-resize, .lf-polyline-append-ew-resize { display: none !important; }

/* 连线纯黑细线 */
.lf-edge path { stroke: #000000 !important; stroke-width: 2px !important; }

/* 节点面板缩略图(卡片预览) - 紧凑单行版 */
.flow-node-item { padding: 2px 0; }
.flow-node-card { display: flex; align-items: center; gap: 5px; padding: 4px 6px; border: 1px solid #e0e0e0; border-left: 3px solid #185FA5; border-radius: 6px; background: #ffffff; cursor: grab; user-select: none; transition: box-shadow .12s, transform .1s; font-size: 11px; white-space: nowrap; overflow: hidden; }
.flow-node-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.1); transform: translateX(2px); }
.fni-icon { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; flex-shrink: 0; }
.fni-label { font-weight: 600; color: #222; line-height: 1.2; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.fni-sub { font-size: 9px; color: #999; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }

/* SVG箭头标记(给连线加箭头) */
#flow-canvas { position: relative; }
.lf-edge polyline, .lf-edge path { stroke: #000000 !important; stroke-width: 2px !important; stroke-dasharray: 0 !important; }
.lf-edge line { stroke: #000000 !important; stroke-width: 2px !important; stroke-dasharray: 0 !important; }
/* 隐藏LogicFlow边编辑手柄(虚线框+▶)和文字标签 */
.lf-edge-append, .lf-edge-append * { display: none !important; }
.lf-edge-marker, .lf-edge-marker * { display: none !important; }
.lf-text { display: none !important; }
text.lf-text, g.lf-text { display: none !important; }

/* 浮动操作按钮 - 确保可见(放在卡片外上方,提高z-index) */
.fc-float-bar { display: none; position: absolute; left: 50%; transform: translateX(-50%); top: -36px; background: #fff; border: 1px solid #d0d0d0; border-radius: 16px; padding: 3px 6px; box-shadow: 0 3px 10px rgba(0,0,0,0.18); z-index: 1000; gap: 2px; }
.flow-card.selected .fc-float-bar { display: flex; }
.fcfb-btn { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 13px; cursor: pointer; font-size: 14px; color: #666; transition: background .12s, color .12s; }
.fcfb-btn:hover { background: #fee; color: #d32f2f; }
.lf-html-node { overflow: visible !important; }
