:root {
  --primary: #2f5597;
  --primary-2: #4472c4;
  --primary-soft: #eaf0fb;
  --primary-line: #cfdcf3;
  --ink: #1b2434;
  --ink-2: #3d4759;
  --muted: #6b7688;
  --muted-2: #8b97a9;
  --line: #e3e9f3;
  --bg: #f4f6fb;
  --card: #ffffff;
  --danger: #cc3527;
  --danger-soft: #fdecea;
  --good: #1a7f52;
  --good-soft: #e9f6ef;
  --warn: #a56400;
  --warn-soft: #fff6e3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(21, 42, 82, .04), 0 8px 24px -18px rgba(21, 42, 82, .25);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- 登录 */

.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(900px 420px at 15% -10%, #dfe9fb 0%, transparent 60%),
    radial-gradient(700px 380px at 100% 100%, #e6eefc 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 32px 26px;
  box-shadow: 0 18px 48px -32px rgba(21, 42, 82, .5), 0 2px 6px rgba(21, 42, 82, .04);
}

.brand-mark { margin-bottom: 14px; }

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.02em;
}

.login-card h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.01em; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }

input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccd7e8;
  border-radius: 9px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(68, 114, 196, .14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--primary-line);
  background: #fff;
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--primary-soft); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #28497f; }
.btn-danger { background: #fff; border-color: #f0c3bf; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-block { width: 100%; padding: 11px; font-size: 14.5px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.login-error {
  margin-top: 12px;
  background: var(--danger-soft);
  border: 1px solid #f4c9c4;
  color: #96271b;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12.5px;
}

.login-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--muted-2); text-align: center; line-height: 1.7; }

/* ---------------------------------------------------------------- 框架 */

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

.side {
  width: 208px;
  flex: 0 0 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-t { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.brand-s { font-size: 10px; color: var(--muted-2); letter-spacing: .1em; text-transform: uppercase; }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: .12s;
}

.nav-item:hover { background: #f4f7fd; color: var(--primary); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-item .ni { width: 16px; text-align: center; font-size: 13px; opacity: .8; }

.side-foot { padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.side-note { font-size: 11px; color: var(--muted-2); line-height: 1.9; }

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

.topbar {
  height: 60px;
  flex: 0 0 60px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.tb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 14px; }

.user-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.tb-link { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.tb-link:hover { color: var(--primary); }

.menu-btn {
  display: none; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; color: var(--ink-2);
}

.view { padding: 22px; max-width: 1320px; width: 100%; }

/* ---------------------------------------------------------------- 卡片与通用 */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-head h3 { margin: 0; font-size: 14.5px; letter-spacing: -.01em; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.section-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.kpi .k-label { font-size: 11.5px; color: var(--muted); }
.kpi .k-value { font-size: 21px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.kpi.hero { background: linear-gradient(135deg, #2f5597, #4674c6); border-color: #2f5597; color: #fff; }
.kpi.hero .k-label, .kpi.hero .k-foot { color: rgba(255, 255, 255, .8); }

.text-danger { color: var(--danger); }
.text-good { color: var(--good); }
.text-warn { color: var(--warn); }

/* ---------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  background: #f2f6fd;
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12px;
  text-align: right;
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th:first-child, tbody td:first-child { text-align: left; }
tbody td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid #eef2f8;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
tbody tr:hover td { background: #f8faff; }
tbody tr.clickable { cursor: pointer; }
tbody tr.total-row td { background: #f2f6fd; font-weight: 700; border-top: 2px solid var(--primary-line); }
td.name-cell { white-space: normal; min-width: 150px; }
td.name-cell .p-name { font-weight: 600; }
td.name-cell .p-meta { font-size: 11.5px; color: var(--muted-2); }
td.wrap { white-space: normal; }

.tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.muted { background: #eef1f7; color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------- 上传 */

.upload-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; align-items: start; }

.drop {
  border: 2px dashed #bfcde6;
  border-radius: var(--radius);
  background: #fbfcff;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
}
.drop:hover, .drop.over { background: var(--primary-soft); border-color: var(--primary-2); }
.drop-icon { font-size: 26px; color: var(--primary-2); line-height: 1; }
.drop-t { font-weight: 700; margin-top: 10px; font-size: 14px; }
.drop-d { color: var(--muted); font-size: 12px; margin-top: 4px; }

.rate-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; background: #f8faff; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 14px; font-size: 12.5px;
}
.rate-row label { font-weight: 700; white-space: nowrap; }
.rate-row input { width: 88px; }
.rate-row .hint { color: var(--muted); flex: 1 1 240px; font-size: 12px; }

.progress-list { margin-top: 14px; }

.msg { border-radius: 10px; padding: 11px 14px; margin-top: 12px; font-size: 12.5px; line-height: 1.75; }
.msg.error { background: var(--danger-soft); color: #96271b; border: 1px solid #f4c9c4; }
.msg.warn { background: var(--warn-soft); color: #855100; border: 1px solid #f2ddb3; }
.msg.ok { background: var(--good-soft); color: #14663f; border: 1px solid #c9e8d8; }
.msg ul { margin: 6px 0 0; padding-left: 18px; }
.msg li { margin: 2px 0; }
.msg b { font-weight: 700; }

.tpl-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fdfefe;
}
.tpl-item .t-name { font-weight: 600; font-size: 13px; }
.tpl-item .t-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- 详情 */

.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.detail-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.detail-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.summary-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }

.sum-hero {
  background: linear-gradient(135deg, #2f5597, #4674c6);
  color: #fff; border-radius: var(--radius); padding: 16px 18px;
  box-shadow: 0 10px 26px -18px rgba(47, 85, 151, .9);
}
.sum-hero .l { font-size: 11.5px; color: rgba(255, 255, 255, .82); }
.sum-hero .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.sum-hero .f { font-size: 11.5px; color: rgba(255, 255, 255, .78); }

.sum-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.sum-box .l { font-size: 11.5px; color: var(--muted); }
.sum-box .v { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sum-box .f { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

.chart-wrap { padding: 6px 4px 0; overflow-x: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--muted); padding: 0 4px 8px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.comp-row {
  display: grid; grid-template-columns: 84px 1fr 106px 52px;
  gap: 12px; align-items: center; padding: 5px 0; font-size: 12.5px;
}
.comp-track { background: #eef2f9; border-radius: 6px; height: 8px; overflow: hidden; }
.comp-bar { background: var(--primary-2); height: 100%; border-radius: 6px; }
.comp-bar.alt { background: #7fa3dd; }
.comp-value { text-align: right; font-variant-numeric: tabular-nums; }
.comp-pct { text-align: right; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.meta-item { background: #f8faff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; }
.meta-item .m-l { font-size: 11px; color: var(--muted); }
.meta-item .m-v { font-size: 15.5px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.empty-state { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty-state .e-icon { font-size: 30px; opacity: .45; }
.empty-state h3 { margin: 12px 0 4px; font-size: 15px; color: var(--ink-2); }
.empty-state p { margin: 0 0 16px; font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text] { width: 240px; }
.toolbar select { width: auto; min-width: 120px; }
.toolbar .spacer { flex: 1; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1b2434; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 100; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5);
  max-width: 88vw;
}
.toast.error { background: #96271b; }

/* ---------------------------------------------------------------- 弹窗 */

.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 32, 56, .42);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 440px;
  box-shadow: 0 24px 60px -20px rgba(15, 30, 60, .5); overflow: hidden;
}
.modal h3 { margin: 0; font-size: 15px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcfe; }
.modal .field { margin-bottom: 12px; }
.modal .field:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 1080px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .kpis, .kpis.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-grid, .two-col { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .side {
    position: fixed; left: 0; top: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .2);
  }
  .side.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .view { padding: 14px; }
  .topbar { padding: 0 14px; }
  .summary-grid { grid-template-columns: 1fr; }
}

@media print {
  .side, .topbar, .detail-actions, .toolbar { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .kpi, .sum-box, .sum-hero { box-shadow: none; }
  tbody tr:hover td { background: transparent; }
  thead th { position: static; }
  @page { size: A4 landscape; margin: 10mm; }
}
