* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #1f2733;
  --muted: #6b7480;
  --primary: #2f6fed;
  --primary-soft: #eaf1fe;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --red: #dc2626;
  --red-soft: #fdecec;
  --orange: #d97706;
  --orange-soft: #fdf3e3;
  --radius: 10px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.layout { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 200px; flex-shrink: 0; background: #1c2536; color: #cbd4e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.logo { font-size: 18px; font-weight: 700; color: #fff; padding: 22px 20px 18px; }
.nav-item {
  display: block; padding: 12px 20px; color: #cbd4e1; text-decoration: none;
  border-left: 3px solid transparent; transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: rgba(47,111,237,.18); color: #fff; border-left-color: var(--primary); }
.sidebar-footer { margin-top: auto; padding: 16px 20px; font-size: 12px; color: #8b96a8; line-height: 1.8; }

/* ---------- main ---------- */
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.page-title small { font-size: 13px; color: var(--muted); font-weight: 400; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type=text], .toolbar input[type=date], .toolbar select,
input.txt, select.sel, textarea.ta {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; background: #fff; color: var(--text); outline: none;
}
.toolbar input[type=text] { width: 210px; }
.toolbar input:focus, .toolbar select:focus, input.txt:focus, textarea.ta:focus { border-color: var(--primary); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border);
  background: #fff; color: var(--text); border-radius: 8px; padding: 7px 13px;
  font-size: 13px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #2158c9; }
.btn.danger { color: var(--red); border-color: #f3c1c1; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 10px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: #fafbfc;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.tbl tr:hover td { background: #f8faff; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .ellip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.group-row td {
  background: #f0f4fb !important; font-weight: 600; padding: 8px 10px;
  border-top: 1px solid var(--border);
}
tr.group-row .g-total { color: var(--primary); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.gray { background: #eef0f3; color: var(--muted); }
.tag-new { background: var(--red); color: #fff; font-size: 11px; border-radius: 4px; padding: 1px 5px; margin-left: 6px; }

/* ---------- selection bar ---------- */
.selbar {
  display: flex; gap: 10px; align-items: center;
  background: #1c2536; color: #fff; border-radius: 12px; padding: 10px 18px;
  box-shadow: 0 3px 12px rgba(0,0,0,.18); margin-bottom: 16px;
}
.selbar .amount { font-size: 16px; font-weight: 700; color: #7fd0ff; }
.selbar .btn { background: transparent; color: #dfe6f0; border-color: #46536b; }
.selbar .btn:hover { border-color: #7fa8f5; color: #fff; }

/* ---------- project cards ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.proj-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: box-shadow .15s; }
.proj-card:hover { box-shadow: 0 4px 16px rgba(30,60,120,.1); }
.proj-card h3 { font-size: 16px; margin-bottom: 6px; }
.proj-card .desc { color: var(--muted); font-size: 12px; min-height: 18px; margin-bottom: 12px; }
.proj-card .meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.proj-card .meta b { color: var(--text); font-size: 15px; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-card .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- charts ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-row .bar-label { width: 110px; text-align: right; color: var(--muted); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; background: #eef1f5; border-radius: 6px; height: 22px; position: relative; }
.bar-row .bar-fill { background: linear-gradient(90deg,#5a8ef5,#2f6fed); height: 100%; border-radius: 6px; min-width: 2px; }
.bar-row .bar-val { width: 190px; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ---------- upload ---------- */
.dropzone {
  border: 2px dashed #c3cddd; border-radius: var(--radius); padding: 44px 20px;
  text-align: center; color: var(--muted); cursor: pointer; transition: all .15s; background: #fbfcfe;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.upl-list { margin-top: 14px; }
.upl-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.upl-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask[hidden], .toast[hidden] { display: none !important; }
.modal {
  background: #fff; border-radius: 14px; max-width: 860px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; font-size: 13px; margin-bottom: 14px; }
.detail-grid .dt { color: var(--muted); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-row input.txt, .form-row textarea.ta { width: 100%; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1c2536; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.err { background: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 44px 0; }
.mini-sel { border: 1px solid transparent; background: transparent; font-size: 12.5px; color: var(--text); padding: 3px 4px; border-radius: 6px; cursor: pointer; max-width: 130px; }
.mini-sel:hover { border-color: var(--border); background: #fff; }
a.link { color: var(--primary); text-decoration: none; cursor: pointer; }
a.link:hover { text-decoration: underline; }
.progress-outer { background: #eef1f5; border-radius: 6px; height: 10px; overflow: hidden; }
.progress-inner { background: var(--primary); height: 100%; transition: width .3s; }

@media (max-width: 860px) {
  .sidebar { width: 60px; }
  .logo { font-size: 14px; padding: 16px 8px; text-align: center; }
  .nav-item { padding: 12px 0; text-align: center; font-size: 18px; }
  .sidebar-footer { display: none; }
  .main { padding: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
}
