/* 咨询型项目与交付管理平台 —— 样式基础
   零外部依赖：不引入字体、图标库或 CDN，全部内联定义，保证政务内网离线可用。 */

:root {
  --c-bg: #f5f7fa;
  --c-panel: #ffffff;
  --c-border: #e2e8f0;
  --c-border-strong: #cbd5e1;
  --c-text: #1e293b;
  --c-text-soft: #64748b;
  --c-text-faint: #94a3b8;
  --c-primary: #1d4ed8;
  --c-primary-dark: #1e40af;
  --c-primary-soft: #eff4ff;
  --c-success: #15803d;
  --c-success-soft: #ecfdf3;
  --c-warn: #b45309;
  --c-warn-soft: #fffbeb;
  --c-danger: #b91c1c;
  --c-danger-soft: #fef2f2;
  --c-info: #0369a1;
  --c-info-soft: #f0f9ff;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.16);
  --sidebar-w: 216px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ── 布局 ─────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.brand-title { color: #f8fafc; font-size: 14px; font-weight: 600; letter-spacing: 0.2px; }
.brand-sub { color: #64748b; font-size: 11px; margin-top: 3px; }

.nav { padding: 10px 8px; flex: 1; }
.nav-section {
  color: #475569;
  font-size: 11px;
  padding: 12px 10px 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(148, 163, 184, 0.12); color: #f1f5f9; text-decoration: none; }
.nav-item.active { background: var(--c-primary); color: #fff; font-weight: 500; }
.nav-item.disabled { opacity: 0.35; pointer-events: none; }
.nav-child { padding-left: 26px; font-size: 12.5px; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; flex: 0 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crumb { color: var(--c-text-soft); font-size: 12.5px; }
.crumb strong { color: var(--c-text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  font-size: 12.5px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

.content { padding: 20px; flex: 1; min-width: 0; }
.content-narrow { max-width: 1100px; }

/* ── 卡片 ─────────────────────────────────────────────── */

.card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--c-border);
}
.card-head h2 { font-size: 14px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── 指标卡 ───────────────────────────────────────────── */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.metric::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c-primary);
}
.metric.is-warn::before { background: var(--c-warn); }
.metric.is-danger::before { background: var(--c-danger); }
.metric.is-success::before { background: var(--c-success); }
.metric-label { color: var(--c-text-soft); font-size: 12px; }
.metric-value { font-size: 26px; font-weight: 650; letter-spacing: -0.5px; margin-top: 2px; }
.metric-value small { font-size: 13px; font-weight: 500; color: var(--c-text-soft); margin-left: 2px; }
.metric-foot { color: var(--c-text-faint); font-size: 11.5px; margin-top: 2px; }

/* ── 表格 ─────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-weight: 600;
  color: var(--c-text-soft);
  font-size: 12px;
  padding: 10px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
/* 可点开的行（任务、问题的详情入口） */
tbody tr.row-click, tbody tr[data-issue] { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; }
.table-empty { padding: 36px 16px; text-align: center; color: var(--c-text-faint); font-size: 13px; }

/* ── 徽标与标签 ───────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.7;
  background: var(--c-bg); color: var(--c-text-soft); border: 1px solid var(--c-border);
  white-space: nowrap;
}
.badge.primary { background: var(--c-primary-soft); color: var(--c-primary-dark); border-color: #c7d7fe; }
.badge.success { background: var(--c-success-soft); color: var(--c-success); border-color: #bbf7d0; }
.badge.warn { background: var(--c-warn-soft); color: var(--c-warn); border-color: #fde68a; }
.badge.danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: #fecaca; }
.badge.info { background: var(--c-info-soft); color: var(--c-info); border-color: #bae6fd; }
.badge.muted { color: var(--c-text-faint); }

.tag {
  display: inline-block; padding: 0 7px; margin: 2px 2px 2px 0;
  border-radius: var(--radius-sm); background: var(--c-primary-soft);
  color: var(--c-primary-dark); font-size: 12px;
}

/* ── 按钮 ─────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--c-border-strong);
  background: var(--c-panel); color: var(--c-text);
  font-size: 13px; font-family: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: #f8fafc; border-color: var(--c-text-faint); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn.primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }
.btn.danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn.danger:hover { background: #991b1b; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-primary); padding: 4px 8px; }
.btn.ghost:hover { background: var(--c-primary-soft); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── 表单 ─────────────────────────────────────────────── */

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--c-text-soft); margin-bottom: 4px; font-weight: 500; }
.field label .req { color: var(--c-danger); margin-left: 2px; }
.field .hint { font-size: 11.5px; color: var(--c-text-faint); margin-top: 3px; }
.input, .select, .textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; color: var(--c-text);
  background: #fff; transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}
.textarea { min-height: 74px; resize: vertical; line-height: 1.55; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--c-danger); }
.field-error { color: var(--c-danger); font-size: 11.5px; margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input, .filters .select { width: auto; min-width: 130px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.check-inline input { width: 14px; height: 14px; cursor: pointer; }

/* ── 模态框 ───────────────────────────────────────────── */

.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
  animation: fadeIn 0.12s ease-out;
}
.modal {
  background: var(--c-panel); border-radius: 10px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px; animation: slideUp 0.15s ease-out;
}
.modal.wide { max-width: 820px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--c-border);
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 18px; }
.modal form { margin: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--c-border); background: #fafbfc;
  border-radius: 0 0 10px 10px;
}
.modal-close {
  background: none; border: none; font-size: 20px; line-height: 1;
  color: var(--c-text-faint); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--c-text); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 提示 ─────────────────────────────────────────────── */

#toast-root {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: #1e293b; color: #f8fafc; font-size: 13px;
  box-shadow: var(--shadow-lg); max-width: 380px;
  animation: slideIn 0.16s ease-out;
}
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
.toast.warn { background: #92400e; }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 登录页 ───────────────────────────────────────────── */

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 100%); padding: 20px; }
.login-card {
  background: #fff; border-radius: 12px; padding: 30px 28px;
  width: 100%; max-width: 372px; box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card .sub { color: var(--c-text-soft); font-size: 12.5px; margin-bottom: 20px; }
.login-accounts {
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--c-border);
  font-size: 11.5px; color: var(--c-text-faint); line-height: 1.9;
}
.login-accounts code { color: var(--c-text-soft); }

/* ── 详情与时间线 ─────────────────────────────────────── */

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--c-text-soft); font-size: 12.5px; }
.kv dd { margin: 0; word-break: break-word; }
.desc-block { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.65; }
.desc-block.muted { color: var(--c-text-faint); }

.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px;
  width: 1px; background: var(--c-border);
}
.tl-item { position: relative; padding-bottom: 15px; }
.tl-item::before {
  content: ""; position: absolute; left: -17px; top: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c-primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--c-border);
}
.tl-title { font-size: 13px; font-weight: 500; }
.tl-meta { font-size: 11.5px; color: var(--c-text-faint); margin-top: 1px; }
.tl-detail { font-size: 12.5px; color: var(--c-text-soft); margin-top: 2px; white-space: pre-wrap; }

/* ── 阶段进度 ─────────────────────────────────────────── */

.steps { display: flex; align-items: center; gap: 0; margin: 4px 0 2px; }
.step { flex: 1; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--c-text-faint); min-width: 0; }
.step-dot {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--c-bg); color: var(--c-text-faint); border: 1px solid var(--c-border-strong);
}
.step.done .step-dot { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.step.done { color: var(--c-text); font-weight: 500; }
.step.current .step-dot { background: #fff; border-color: var(--c-primary); color: var(--c-primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14); }
.step.current { color: var(--c-primary-dark); font-weight: 600; }
.step-line { flex: 1; height: 1px; background: var(--c-border); margin: 0 8px; min-width: 12px; }
.step-line.done { background: var(--c-primary); }

/* ── 其他 ─────────────────────────────────────────────── */

.section-title { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--c-text); }
.muted { color: var(--c-text-soft); }
.faint { color: var(--c-text-faint); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

.notice {
  padding: 10px 13px; border-radius: var(--radius-sm); font-size: 12.5px;
  border: 1px solid var(--c-border); background: var(--c-bg); color: var(--c-text-soft);
  margin-bottom: 12px;
}
.notice.info { background: var(--c-info-soft); border-color: #bae6fd; color: #075985; }
.notice.warn { background: var(--c-warn-soft); border-color: #fde68a; color: #92400e; }
.notice.danger { background: var(--c-danger-soft); border-color: #fecaca; color: #991b1b; }
.notice.success { background: var(--c-success-soft); border-color: #bbf7d0; color: #166534; }
.notice strong { font-weight: 600; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 13px; }
.check-mark { flex: 0 0 16px; font-weight: 700; }
.check-mark.ok { color: var(--c-success); }
.check-mark.bad { color: var(--c-danger); }

.loading { padding: 40px; text-align: center; color: var(--c-text-faint); font-size: 13px; }
.error-box { padding: 20px; text-align: center; }
.error-box .msg { color: var(--c-danger); font-size: 13px; margin-bottom: 10px; }

.ai-box {
  border: 1px solid #c7d7fe; background: #f8fbff;
  border-radius: var(--radius); padding: 13px 15px; margin-top: 12px;
}
.ai-box h4 { font-size: 12.5px; color: var(--c-primary-dark); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.ai-field { margin-bottom: 9px; font-size: 12.5px; }
.ai-field .k { color: var(--c-primary-dark); font-weight: 600; }
.ai-field .v { color: var(--c-text); white-space: pre-wrap; }
.ai-foot { font-size: 11.5px; color: var(--c-text-soft); border-top: 1px dashed #c7d7fe; padding-top: 8px; margin-top: 8px; }

.file-input { font-size: 12.5px; }
.help-list { font-size: 12.5px; color: var(--c-text-soft); padding-left: 18px; margin: 6px 0; }
.help-list li { margin-bottom: 3px; }

/* ── 移动端导航：汉堡按钮 + 抽屉 + 遮罩 ─────────────────── */

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px; height: 40px;
  padding: 0 9px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel);
  cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; background: var(--c-text); border-radius: 2px; }
.nav-toggle:active { background: var(--c-bg); }

.nav-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
}
.nav-scrim.show { display: block; }

/* ── 平板：侧栏收窄 ─────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 184px; }
}

/* ── 手机 / 窄屏（≤760px）─────────────────────────────── */
@media (max-width: 760px) {
  .nav-toggle { display: flex; }

  .layout { display: block; }

  /* 侧栏改为从左侧滑出的抽屉 */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 82vw;
    max-width: 300px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .content { padding: 12px; }
  .card-body { padding: 12px; }
  .card-head { padding: 11px 12px; flex-wrap: wrap; }
  .card-actions { width: 100%; }
  .card-actions .btn { flex: 1 1 auto; justify-content: center; }

  .topbar { padding: 0 12px; height: 52px; }
  .topbar-right { gap: 8px; }
  .topbar-right .badge { display: none; }
  .user-chip { padding: 3px 8px 3px 3px; font-size: 12px; }
  .crumb { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }

  /* 指标卡：两列铺满 */
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric { padding: 12px; }

  /* 详情键值表单列 */
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .kv dd { margin-bottom: 4px; }

  /* 阶段条：紧凑、可横滑，不换行挤压 */
  .steps { overflow-x: auto; padding-bottom: 4px; gap: 0; }
  .step { font-size: 11.5px; gap: 5px; flex: 0 0 auto; white-space: nowrap; }
  .step-dot { flex: 0 0 auto; }
  .step-line { min-width: 10px; margin: 0 4px; }

  /* 筛选区：控件满宽堆叠 */
  .filters { flex-direction: column; align-items: stretch; }
  .filters .input, .filters .select { width: 100%; min-width: 0; }

  /* 表格：容器横滑，首列不折行 */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { font-size: 12.5px; }
  th, td { padding-left: 8px; padding-right: 8px; }

  /* 触控热区：按钮与表单控件至少 40px 高 */
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  .nav-item { padding: 11px 10px; font-size: 14px; }
  .input, .select, .textarea { min-height: 40px; }

  /* 弹窗：移动端近乎全屏 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; }
  .modal-body { max-height: 68vh; overflow-y: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row, .form-row-2 { grid-template-columns: 1fr; }
}

/* ── 超窄屏（≤420px）微调 ───────────────────────────────── */
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .crumb { max-width: 34vw; }
}
