:root {
  --primary: #1F3864;
  --primary-dark: #16294a;
  --primary-light: #2c4a80;
  --accent: #3b6fd6;
  --danger: #c0392b;
  --danger-dark: #a2301f;
  --success: #1e7e34;
  --warning: #b8860b;
  --text: #1d2939;
  --text-muted: #667085;
  --border: #e4e7ec;
  --bg: #f4f6f8;
  --surface: #ffffff;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  background: var(--primary);
  color: white;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.topbar .brand { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.topbar nav { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: #dce6f1;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover { color: white; background: rgba(255,255,255,0.10); }
.topbar nav a.active { color: white; background: rgba(255,255,255,0.16); font-weight: 600; }
.user-info { margin-left: auto; font-size: 14px; color: #dce6f1; display: flex; align-items: center; gap: var(--space-3); }
.user-info a { color: #ffd166; text-decoration: none; }
.user-info a:hover { text-decoration: underline; }

.container { max-width: 1140px; margin: var(--space-5) auto; padding: 0 var(--space-4); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: 0 1px 3px rgba(16,24,40,0.06);
}
.card h2, .card h3 { margin-top: 0; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: var(--space-6) 0 var(--space-3);
  color: var(--primary);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

/* 任务详情页页签（报价/实际记录/对外结算/对内报销/内部成本核算），纯CSS+data-*驱动，见table-tools.js */
.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 2px solid var(--border);
  margin: var(--space-5) 0 0;
  flex-wrap: wrap;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  border-radius: 0;
}
.tab-btn:hover { color: var(--primary); background: none; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; padding-top: var(--space-5); }
.tab-panel.active { display: block; }

table { width: 100%; border-collapse: collapse; margin-top: var(--space-2); overflow: hidden; border-radius: 6px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { background: var(--primary); color: white; font-weight: 600; }
tbody tr:nth-child(even) { background: #fafbfc; }
tr:hover td { background: #eef3fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.section-row { background: #eef1f6 !important; font-weight: 600; color: var(--primary); }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* 列表页 搜索/筛选 工具条 */
.table-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center;
  margin-top: var(--space-3); margin-bottom: var(--space-1);
}
.table-toolbar .search-input { max-width: 260px; }
.table-toolbar select { width: auto; min-width: 140px; }
.table-toolbar label { display: inline; margin: 0; font-weight: 500; color: var(--text-muted); }

/* 可排序表头 */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--primary-light); }
th.sortable::after { content: "\2195"; margin-left: 6px; opacity: 0.45; font-size: 12px; }
th.sort-asc::after { content: "\2191"; opacity: 1; }
th.sort-desc::after { content: "\2193"; opacity: 1; }

form.inline { display: inline; }
label { display: block; margin: var(--space-3) 0 var(--space-1); font-size: 13px; font-weight: 600; color: var(--text); }
input, select, textarea {
  padding: 8px 10px; border: 1px solid #cfd4dc; border-radius: 6px; width: 100%; font-size: 14px;
  background: white; color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,111,214,0.15);
}

button, .btn {
  background: var(--primary); color: white; border: none; padding: 9px 18px;
  border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500;
  text-decoration: none; display: inline-block; transition: background 0.15s, box-shadow 0.15s;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #545b64; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: var(--space-4); font-size: 14px; }
.flash-success { background: #d4edda; color: #155724; border: 1px solid #b6dfc0; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f0b7bd; }

.badge { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-normal { background: #e4e7ec; color: #344054; }
.badge-ot15 { background: #ffedb8; color: #7a5b00; }
.badge-ot20 { background: #ffd0d0; color: #8a1f1f; }

/* 状态类标签：批准状态/CRM状态复用同一套三档配色（待处理/完成态/否决态） */
.badge-pending { background: #e4e7ec; color: #344054; }
.badge-info { background: #d6e4ff; color: #1c3d8f; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-rejected { background: #ffd0d0; color: #8a1f1f; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.stat { text-align: center; padding: var(--space-3); border-radius: 8px; }
.stat.stat-revenue { background: #eef3fb; }
.stat.stat-cost { background: #fdf3ea; }
.stat.stat-profit { background: #ecf7ee; }
.stat .value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* 管理看板"按项目类型汇总"卡片 */
.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}
.type-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-4);
  background: var(--surface);
}
.type-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.type-card-header .type-name { font-weight: 700; font-size: 15px; color: var(--primary); }
.type-card-header .type-count { font-size: 12px; color: var(--text-muted); background: var(--bg); padding: 2px 10px; border-radius: 10px; }
.type-card-stats { display: flex; justify-content: space-between; text-align: center; }
.type-card-stats .value { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.type-card-stats .label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.type-card-margin { text-align: center; margin-top: var(--space-3); font-size: 13px; color: var(--text-muted); }

@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { gap: var(--space-3); }
  .container { padding: 0 var(--space-3); }
}
