/* ============================================================================
   任务推进系统 · 全局样式
   视觉基调：深海军蓝侧栏 + 靛蓝主色 + 柔和暖灰底，大气优雅、专业克制
   ============================================================================ */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #16222f;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e5e9ef;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;
  --teal: #0d9488;
  --danger: #dc2626;
  --sidebar-bg: #0c1a2a;
  --sidebar-hover: #12293f;
  --sidebar-text: #aab8c8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 25, 40, .05), 0 8px 30px rgba(15, 25, 40, .07);
  --shadow-sm: 0 1px 2px rgba(15, 25, 40, .05);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: .85em; }
.inline { display: inline; }

/* ---------------- 布局框架 ---------------- */
.app-body { min-height: 100vh; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), #0a1420);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px;
}

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
}
.brand-mark-lg { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.is-active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.3); }
.nav-ico { width: 20px; text-align: center; opacity: .9; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; flex-shrink: 0;
}
.sidebar-user-meta { flex: 1; min-width: 0; }
.sidebar-user-meta strong { display: block; color: #fff; font-size: 13px; }
.sidebar-user-meta small { color: var(--faint); font-size: 12px; }
.logout { color: var(--faint); font-size: 18px; padding: 4px 6px; }
.logout:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 30px;
  background: rgba(244,246,249,.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title h1 { font-size: 21px; font-weight: 700; letter-spacing: .3px; }

.content { padding: 24px 30px 48px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.2;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.28);
}
.btn-primary:hover { filter: brightness(1.06); color: #fff; box-shadow: 0 6px 18px rgba(37,99,235,.35); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------- 表单 ---------------- */
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.field-hint { font-size: 12px; color: var(--faint); margin-top: 6px; }
.input {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg,transparent 50%,#94a3b8 50%),linear-gradient(135deg,#94a3b8 50%,transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.file { padding: 9px 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 10px; }

.color-picker { display: flex; gap: 12px; flex-wrap: wrap; }
.color-swatch { cursor: pointer; }
.color-swatch input { position: absolute; opacity: 0; }
.color-swatch span {
  --sw: #2563eb;
  display: inline-block; width: 30px; height: 30px; border-radius: 50%;
  background: var(--sw);
  border: 2px solid transparent;
  transition: transform .12s;
}
.color-swatch input:checked + span { transform: scale(1.18); border-color: #fff; box-shadow: 0 0 0 2px var(--sw); }

/* ---------------- Flash ---------------- */
.flash-stack { padding: 0 30px; max-width: 1240px; margin: 14px auto 0; }
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  border: 1px solid;
}
.flash-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* ---------------- 统计 ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 30px; font-weight: 700; line-height: 1; }
.stat-label { margin-top: 6px; color: var(--muted); font-size: 13px; }
.stat-accent .stat-num { color: var(--teal); }

/* ---------------- 项目卡片 ---------------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s, box-shadow .15s;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.project-card-head { display: flex; align-items: center; gap: 10px; }
.project-dot { --dot: #2563eb; width: 12px; height: 12px; border-radius: 4px; background: var(--dot); flex-shrink: 0; }
.project-name { font-size: 16px; font-weight: 700; }
.project-desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.project-metrics { display: flex; gap: 8px; }
.metric { flex: 1; background: #f8fafc; border-radius: var(--radius-sm); padding: 10px 8px; text-align: center; }
.metric strong { display: block; font-size: 18px; }
.metric small { color: var(--muted); font-size: 12px; }
.project-card-foot { display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: 12px; }
.project-arrow { color: var(--accent); font-weight: 700; }

/* ---------------- 面板 / 空态 ---------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.panel-narrow { max-width: 680px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sec-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty.small { padding: 30px 20px; }
.empty-ico { font-size: 40px; margin-bottom: 12px; color: var(--faint); }
.empty p { margin-bottom: 16px; }

/* ---------------- 面包屑 / hero ---------------- */
.breadcrumb { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.bc-sep { color: var(--faint); }
.project-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-left: 4px solid var(--hero, var(--accent)); }
.project-hero h2 { font-size: 20px; }

/* ---------------- 需求列表 ---------------- */
.demand-list { display: flex; flex-direction: column; gap: 12px; }
.demand-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}
.demand-item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.demand-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.demand-meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.demand-item-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.chip { background: #eef2f7; color: var(--muted); font-size: 12px; padding: 4px 10px; border-radius: 20px; }
.chip-done { background: #ecfdf5; color: #047857; }

/* ---------------- 附件 ---------------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.file-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow .15s;
  position: relative;
}
.file-card:hover { box-shadow: var(--shadow-sm); }
.file-media img, .file-media video { border-radius: 6px; max-height: 150px; width: 100%; object-fit: cover; background:#eef2f7; }
.file-preview { display: block; }
.file-ico { font-size: 30px; color: var(--accent); text-align: center; }
.file-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--faint); }
.file-dl {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(15, 25, 40, .5); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; text-decoration: none; line-height: 1;
  opacity: 0; transition: opacity .15s, background .15s; z-index: 2;
}
.file-card:hover .file-dl { opacity: 1; }
.file-dl:hover { background: var(--accent); color: #fff; }

/* ---------------- 七牛上传列表 ---------------- */
.qiniu-filelist { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.qiniu-file {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.qf-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qf-size { color: var(--faint); font-size: 12px; flex: none; }
.qf-state { font-size: 12px; flex: none; }
.qf-state.ok { color: #047857; }
.qf-rm { flex: none; border: none; background: transparent; color: var(--danger); cursor: pointer; font-size: 12px; padding: 4px 6px; }

/* ---------------- 分支 ---------------- */
.branch-list { display: flex; flex-direction: column; gap: 12px; }
.branch-list.wide { margin-top: 18px; }
.branch-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
}
.branch-link { color: var(--ink); transition: box-shadow .15s; }
.branch-link:hover { box-shadow: var(--shadow); color: var(--ink); }
.branch-main { flex: 1; min-width: 0; }
.branch-title { font-weight: 600; font-size: 15px; }
.branch-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.branch-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.branch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.branch-head-status { flex-shrink: 0; }
.branch-ops { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.inline-form { margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: #f8fafc; border-radius: var(--radius-sm); }

/* ---------------- 徽章 ---------------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.badge-gray   { background: #eef2f7; color: #475569; }
.badge-amber  { background: #fef3c7; color: #b45309; }
.badge-green  { background: #d1fae5; color: #047857; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-slate  { background: #e2e8f0; color: #475569; }
.badge-red    { background: #fee2e2; color: #b91c1c; }

/* ---------------- 状态筛选 ---------------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.filter-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-num { opacity: .8; }

/* ---------------- 日志 ---------------- */
.log-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.log-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: #f8fafc; border-radius: var(--radius-sm); }
.log-time { color: var(--faint); font-size: 12px; min-width: 130px; }
.log-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--muted); }
.log-by { color: var(--muted); font-size: 13px; }

/* ---------------- 登录/注册 ---------------- */
.auth-body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 20% -10%, #e7f0ff, transparent),
              radial-gradient(1000px 500px at 110% 110%, #e6f7f5, transparent),
              var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.auth-wrap { width: 100%; max-width: 440px; }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .brand-mark { margin: 0 auto 14px; }
.auth-brand h1 { font-size: 26px; letter-spacing: 1px; }
.auth-brand p { color: var(--muted); margin-top: 6px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ---------------- 响应式 / 移动端适配 ---------------- */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-size: 18px; cursor: pointer;
}
.sidebar-mask {
  display: none;
  position: fixed; inset: 0; z-index: 25;
  background: rgba(15, 25, 40, .45);
  opacity: 0; visibility: hidden;
  transition: opacity .2s, visibility .2s;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .sidebar-mask { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-mask { opacity: 1; visibility: visible; }
  .main { width: 100%; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar-title { display: flex; align-items: center; gap: 10px; }
  .topbar-title h1 { font-size: 17px; }
  .file-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-actions, .head-actions, .branch-head-status { flex-wrap: wrap; }
  .project-hero { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .file-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .topbar-actions .btn-sm { padding: 7px 10px; font-size: 12px; }
  .table th, .table td { padding: 8px 10px; }
  .breadcrumb { font-size: 12px; }
  .sidebar { width: 232px; }
}

/* ---------------- 管理端：删除按钮 / 用户管理 ---------------- */
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.branch-head-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.table tbody tr:hover td { background: #f8fafc; }
.table code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* 用户管理：角色下拉设置 */
.role-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.select-sm { width: auto; min-width: 116px; padding: 6px 10px; font-size: 13px; }

/* 新增需求/分支表单内联操作区（供 hero/head 右侧按钮用） */
.inline-form .form-actions { display: flex; gap: 8px; }

/* ---------------- 思维导图 ---------------- */
.map-shell { display: flex; flex-direction: column; }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.map-hint { font-size: 13px; color: var(--muted); }
.map-hint b { color: var(--ink); }
.map-zoom { display: flex; align-items: center; gap: 8px; }
.map-scale { min-width: 52px; text-align: center; font-size: 13px; color: var(--muted); }
.map-help { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.map-help b { color: var(--accent); }
.map-canvas { position: relative; overflow: auto; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); height: calc(100vh - 220px); min-height: 340px; touch-action: none; }
.map-viewport { position: relative; transform-origin: 0 0; }
.map-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.map-node { position: absolute; display: flex; align-items: center; gap: 8px; width: 228px; height: 40px; padding: 0 10px; background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow-sm); cursor: pointer; }
.map-node:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.map-fold { flex: none; width: 30px; height: 30px; border: none; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #1e40af); color: #fff; font-size: 17px; font-weight: 700; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 2px 8px rgba(37, 99, 235, .38); transition: transform .15s ease, box-shadow .15s ease; }
.map-fold:hover { transform: scale(1.12); box-shadow: 0 4px 14px rgba(37, 99, 235, .5); }
.map-fold:active { transform: scale(.96); }
.map-fold-none { background: transparent; box-shadow: none; transform: none; width: 30px; height: 30px; flex: none; }
.map-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.map-link { flex: 1; min-width: 0; color: var(--ink); font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-link.is-link:hover { color: var(--accent); }
.map-link.is-root { font-weight: 700; }
.map-meta { flex: none; font-size: 11px; color: var(--muted); background: #eef2f7; padding: 2px 6px; border-radius: 6px; white-space: nowrap; max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) {
  .map-canvas { height: calc(100vh - 200px); }
}
