:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* 登录页 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.login-box { background: #fff; padding: 40px 36px; border-radius: 16px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center; }
.login-logo { font-size: 48px; }
.login-logo-img { width: 260px; max-width: 90%; margin-bottom: 20px; border-radius: 6px; }
.login-box h1 { font-size: 20px; margin: 12px 0 4px; }
.login-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-msg { color: var(--danger); margin-top: 12px; font-size: 13px; min-height: 18px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; transition: transform 0.25s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid #1e293b; }
.brand-logo { width: 100%; max-width: 188px; display: block; }
.brand-icon { font-size: 24px; }
.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 13px 20px; color: #cbd5e1; text-decoration: none; transition: 0.15s; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 16px; border-top: 1px solid #1e293b; }
.user-info { font-size: 13px; margin-bottom: 10px; color: #94a3b8; }
.user-info strong { color: #fff; display: block; }

.main { flex: 1; margin-left: 220px; }
.topbar { background: #fff; padding: 14px 24px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar h2 { font-size: 18px; }
.menu-toggle { display: none; font-size: 20px; background: none; border: none; cursor: pointer; }
.content { padding: 24px; }

/* 卡片与通用 */
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer; font-size: 14px; transition: 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: #cbd5e1; border: 1px solid #334155; }
.btn-ghost:hover { background: #1e293b; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.kpi-label { color: var(--text-muted); font-size: 13px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi-value.green { color: var(--success); }
.kpi-value.blue { color: var(--primary); }
.kpi-value.orange { color: var(--warning); }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-card { background: var(--card); border-radius: 12px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.chart-card h3 { font-size: 15px; margin-bottom: 12px; }
.chart { width: 100%; height: 300px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: #f8fafc; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.toolbar-left { display: flex; gap: 10px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 12px; }
.badge-green { background: #dcfce7; color: var(--success); }
.badge-blue { background: #dbeafe; color: var(--primary); }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }
.badge-orange { background: #fef3c7; color: var(--warning); }
.badge-red { background: #fee2e2; color: var(--danger); }

.hidden { display: none !important; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* 项目进度（AIDP） */
.prog-card { margin-bottom: 16px; }
.prog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 13px; background: #f8fafc; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.num.up { color: var(--success); font-weight: 600; }
.num.down { color: var(--danger); font-weight: 600; }
.num.flat, .muted { color: var(--text-muted); }
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.site-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.site-name { font-weight: 600; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,0.15); }
.dot-red { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.15); }

/* ===== 项目管理台 ===== */
.proj-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.proj-toolbar-right { display: flex; gap: 10px; }
.proj-filter select { padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; min-width: 160px; }

/* 今日 / 本周 / 本月 统计条 —— 紧凑，一行三块 */
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-mini { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px 12px; }
.stat-mini-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--text-muted); margin-bottom: 7px; }
.stat-mini-top b { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.mini-bar { height: 5px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #16a34a); border-radius: 6px; transition: width .3s; }

/* 标签页 —— 白底卡片式，紧凑 */
.proj-tabs { display: flex; gap: 4px; margin-bottom: 0; padding: 0 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px 10px 0 0; border-bottom: none; }
.ptab { background: none; border: none; padding: 11px 20px; font-size: 14px; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; }
.ptab:hover { color: var(--text); }
.ptab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 任务列表 —— 统一行高 + 斑马纹，去掉"松" */
.task-list { display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--border); border-radius: 0 0 10px 10px; padding: 2px 8px 8px; }
.task-list > .task-list-title { padding: 10px 8px 8px; font-size: 13px; color: var(--text-muted);
  font-weight: 600; letter-spacing: .3px; border-bottom: 1px solid #f1f5f9; margin-bottom: 4px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 0 8px; height: 42px;
  border-radius: 8px; flex-shrink: 0; transition: background .12s; border-bottom: 1px solid #f6f8fb; }
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #eff6ff; }
.task-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-check { cursor: pointer; font-size: 17px; color: var(--primary); user-select: none; flex-shrink: 0; line-height: 1; }
.task-title { flex: 1; cursor: pointer; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-proj { font-size: 12px; color: var(--primary); background: #dbeafe; padding: 2px 9px; border-radius: 20px; flex-shrink: 0; }
.task-assignee { font-size: 12px; color: var(--text-muted); background: #f1f5f9; padding: 2px 9px; border-radius: 20px; flex-shrink: 0; }
.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.task-row:hover .task-actions { opacity: 1; }
.btn-ico { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); padding: 3px 7px; border-radius: 5px; }
.btn-ico:hover { background: #e2e8f0; color: var(--text); }
.btn-ico.danger:hover { background: #fee2e2; color: var(--danger); }
.prio-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.prio-high { background: #dc2626; }
.prio-normal { background: #f59e0b; }
.prio-low { background: #94a3b8; }

/* 项目卡片 —— 高度收窄，信息分层 */
.proj-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: 12px; }
.proj-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.pc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.pc-head h3 { margin: 0; font-size: 15px; }
.pc-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-bar { position: relative; height: 18px; background: #f1f5f9; border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.pc-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #16a34a); }
.pc-bar span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 600; color: var(--text); }
.pc-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.pc-dl { color: var(--danger); font-weight: 600; }
.muted-sm { font-size: 12px; color: var(--text-muted); font-weight: normal; }

/* ===== 业务线板块分组 ===== */
.biz-block { margin-bottom: 22px; }
.biz-block:last-child { margin-bottom: 0; }
.biz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding: 10px 14px; background: linear-gradient(90deg, #eff6ff, #f8fafc);
  border-left: 3px solid var(--primary); border-radius: 8px; }
.biz-icon { font-size: 20px; }
.biz-name { font-size: 16px; font-weight: 700; }
.biz-count { font-size: 12px; color: var(--primary); background: #dbeafe; padding: 2px 10px; border-radius: 20px; }
.biz-desc { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* ===== 风险预警条 ===== */
.risk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fed7aa; font-size: 13px; }
.risk-bar.risk-ok { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.risk-title { font-weight: 700; color: #c2410c; flex-shrink: 0; }
.risk-item { padding: 3px 10px; border-radius: 20px; cursor: default; white-space: nowrap; }
.risk-item.risk-high { background: #fee2e2; color: #b91c1c; }
.risk-item.risk-mid { background: #ffedd5; color: #c2410c; }
.risk-item.risk-low { background: #fef9c3; color: #a16207; }
.risk-more { color: var(--text-muted); font-size: 12px; }

/* ===== 经营目标 ===== */
.rt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.rt-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: #fff; }
.rt-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.rt-name { font-size: 14px; color: var(--text-muted); }
.rt-rate { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rt-rate small { font-size: 10px; font-weight: 400; color: var(--text-muted); }
.rt-good { color: #16a34a; } .rt-mid { color: #f59e0b; } .rt-bad { color: #dc2626; }
.rt-nums { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; }
.rt-nums b { font-size: 24px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.rt-nums span { font-size: 12px; color: var(--text-muted); }
.rt-bar { height: 7px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.rt-bar i { display: block; height: 100%; border-radius: 6px; transition: width .4s; }
.rt-bar i.rt-good { background: linear-gradient(90deg, #22c55e, #16a34a); }
.rt-bar i.rt-mid { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.rt-bar i.rt-bad { background: linear-gradient(90deg, #f87171, #dc2626); }
.rt-proj { padding: 12px 0; border-top: 1px solid #f1f5f9; }
.rt-proj:first-of-type { border-top: none; padding-top: 4px; }
.rt-proj-head { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

/* ===== 项目开发流程（标准 7 阶段） ===== */
.pc-src { font-size: 12px; color: var(--text-muted); }

.flow-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.flow-title { display: flex; align-items: baseline; gap: 14px; }
.flow-title h2 { margin: 0; font-size: 20px; }
.flow-prog { font-size: 14px; color: var(--text-muted); }
.flow-prog b { font-size: 22px; color: var(--primary); font-variant-numeric: tabular-nums; }
.flow-region { font-size: 13px; color: var(--text-muted); }
.flow-actions { display: flex; gap: 8px; margin-left: auto; }

.flow-progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.flow-progress-bar { flex: 1; height: 12px; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.flow-progress-bar i { display: block; height: 100%; border-radius: 8px;
  background: linear-gradient(90deg, #2563eb, #16a34a); transition: width .4s; }
.flow-progress-tip { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

.flow-empty-card { text-align: center; padding: 40px 24px; }
.flow-empty-card p { margin-bottom: 8px; }
.flow-type-pick { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.flow-type-pick select { padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; }

/* 阶段网格 —— 7 阶段横向时间轴 */
.flow-stages { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.flow-stage { border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 10px 12px;
  display: flex; flex-direction: column; min-height: 200px; position: relative; }
.flow-stage::after { content: ''; position: absolute; top: 22px; right: -10px; width: 10px; height: 2px;
  background: var(--border); }
.flow-stage:last-child::after { display: none; }
.flow-stage.flow-done { border-color: #bbf7d0; background: #f0fdf4; }
.flow-stage.flow-doing { border-color: #bfdbfe; background: #eff6ff; box-shadow: 0 2px 10px rgba(37,99,235,.1); }
.fs-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.fs-icon { font-size: 15px; }
.fs-name { font-weight: 600; font-size: 14px; }
.fs-pct { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.flow-done .fs-pct { color: var(--success); font-weight: 600; }
.fs-nodes { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.fs-node { display: flex; align-items: flex-start; gap: 6px; padding: 5px 5px; border-radius: 6px;
  font-size: 12.5px; transition: background .12s; }
.fs-node:hover { background: #f1f5f9; }
.fs-node.node-done .fn-name { text-decoration: line-through; color: var(--text-muted); }
.fn-chk { cursor: pointer; font-size: 14px; color: var(--primary); flex-shrink: 0; user-select: none; line-height: 1.25; }
.fn-name { flex: 1; cursor: pointer; line-height: 1.35; word-break: break-all; }
.fn-w { font-size: 10px; color: #94a3b8; background: #f1f5f9; padding: 0 5px; border-radius: 8px;
  flex-shrink: 0; margin-top: 1px; }
.fn-actions { display: none; gap: 0; flex-shrink: 0; }
.fs-node:hover .fn-actions { display: flex; }
.fs-empty { font-size: 12px; color: #cbd5e1; padding: 6px; }

@media (max-width: 1400px) {
  .flow-stages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .flow-stage:nth-child(4)::after { display: none; }
}

@media (max-width: 768px) {
  .stat-strip { grid-template-columns: 1fr; }
  .proj-toolbar { flex-direction: column; align-items: stretch; }
  .proj-cards { grid-template-columns: 1fr; }
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .chart-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .site-grid { grid-template-columns: 1fr; }
  .data-table th, .data-table td { padding: 7px 6px; font-size: 13px; }
}

/* ===== 门店/加盟（加盟店汇总） ===== */
#store-table th, #store-table td,
.modal table th, .modal table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px;
}
#store-table th, .modal table th { color: var(--text-muted); font-weight: 600; font-size: 12px; background: #f8fafc; white-space: nowrap; }
#store-table tbody tr:hover { background: #f8fafc; }
.cell-wrap { max-width: 180px; white-space: normal; line-height: 1.4; }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 4px; }
.plate { display: inline-block; padding: 1px 7px; border-radius: 4px; background: #dbeafe; color: #1e40af; font-size: 12px; font-weight: 600; }
.link-store { color: var(--primary, #2563eb); text-decoration: none; font-weight: 600; }
.link-store:hover { text-decoration: underline; }
.sum-chip { display: inline-block; margin-left: 10px; padding: 4px 10px; border-radius: 6px; background: #f1f5f9; font-size: 13px; color: var(--text-muted); }
.sum-chip b { color: var(--text); }

/* 门店详情弹窗 */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.detail-grid > div.full { grid-column: 1 / -1; }
.detail-grid label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.detail-grid > div > div { font-size: 14px; line-height: 1.5; }
.sub { font-size: 12px; color: var(--text-muted); }
.modal { max-width: 760px; }
.sum-chip-main { background: #dbeafe; color: #1e40af; font-size: 14px; padding: 5px 14px; }
.sum-chip-main b { color: #1e3a8a; font-size: 16px; }
.stu-done { color: #1e40af; font-weight: 700; }
.flag-ok { display:inline-block; padding:1px 8px; border-radius:10px; background:#dcfce7; color:#166534; font-size:12px; font-weight:600; }
.flag-no { display:inline-block; padding:1px 8px; border-radius:10px; background:#f1f5f9; color:#64748b; font-size:12px; }
.tra-tab { background:#f1f5f9; color:#475569; border:1px solid transparent; }
.tra-tab.active { background:#dbeafe; color:#1e40af; border-color:#93c5fd; font-weight:700; }
.pill { display:inline-block; padding:2px 10px; border-radius:12px; font-size:12px; font-weight:600; text-decoration:none; white-space:nowrap; }
.pill-contract { background:#dcfce7; color:#166534; border:1px solid #86efac; }
.pill-contract:hover { background:#bbf7d0; }
.pill-none { background:#f1f5f9; color:#94a3b8; border:1px solid #e2e8f0; }

/* 到期时间 + 倒计时 */
.exp-box { display:flex; flex-direction:column; gap:3px; line-height:1.3; }
.exp-date { font-size:13px; color:var(--text); font-variant-numeric:tabular-nums; }
.exp-badge { display:inline-block; align-self:flex-start; padding:1px 8px; border-radius:10px; font-size:11px; font-weight:600; white-space:nowrap; }
.exp-ok { background:#dcfce7; color:#166534; }
.exp-warn { background:#fef3c7; color:#b45309; }
.exp-danger { background:#fee2e2; color:#b91c1c; }
.exp-expired { background:#dc2626; color:#fff; }
.exp-none { color:#94a3b8; font-size:12px; }
.sum-chip-danger { background:#fee2e2; color:#b91c1c; }
.sum-chip-danger b { color:#991b1b; }
.sum-chip-warn { background:#fef3c7; color:#b45309; }
.sum-chip-warn b { color:#92400e; }
