/* ============================================================
   项目效能度量仪表盘 - 样式表
   深色科技主题 · 响应式 · 与邮件周报视觉统一
   ============================================================ */

:root {
  --bg-0: #0b1120;
  --bg-1: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #273449;
  --line: rgba(99, 102, 241, 0.18);
  --line-strong: rgba(99, 102, 241, 0.35);
  --txt-0: #f1f5f9;
  --txt-1: #e2e8f0;
  --txt-2: #94a3b8;
  --txt-3: #64748b;
  --brand: #6366f1;
  --brand-lt: #818cf8;
  --brand-dk: #4f46e5;
  --purple: #8b5cf6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --pink: #f472b6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(900px 500px at 85% 0%, rgba(139, 92, 246, 0.12), transparent 55%),
    linear-gradient(170deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  color: var(--txt-1);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand-dk), var(--purple));
  display: grid; place-items: center; font-size: 17px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.brand-txt h1 { font-size: 16px; font-weight: 700; color: var(--txt-0); letter-spacing: .2px; }
.brand-txt p { font-size: 11px; color: var(--txt-3); letter-spacing: 1.4px; text-transform: uppercase; }

.tool-group { display: flex; align-items: center; gap: 8px; }

.field { display: flex; align-items: center; gap: 6px; }
.field label { font-size: 12px; color: var(--txt-3); white-space: nowrap; }
.select {
  background: var(--bg-2); color: var(--txt-1);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 13px; cursor: pointer; outline: none;
  min-width: 132px; transition: border-color .18s;
}
.select:hover { border-color: var(--brand-lt); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(99, 102, 241, 0.16); color: #c7d2fe;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 13px; font-size: 13px; cursor: pointer;
  transition: background .18s, transform .12s; white-space: nowrap;
}
.btn:hover { background: rgba(99, 102, 241, 0.3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-dk), var(--purple));
  color: #fff; border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.12); background: linear-gradient(135deg, var(--brand-dk), var(--purple)); }
.btn-icon {
  position: relative; width: 36px; height: 36px; padding: 0;
  justify-content: center; font-size: 16px;
}
.badge-dot {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--bg-1);
}

/* ---------------- Meta strip ---------------- */
.meta-strip {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  padding: 14px 18px; margin-bottom: 18px;
  background: rgba(30, 41, 59, 0.5); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.meta-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--txt-2); }
.meta-item b { color: var(--txt-1); font-weight: 600; }
.chip {
  padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(99, 102, 241, 0.18); color: #c7d2fe; border: 1px solid var(--line-strong);
}
.chip.live { background: rgba(34, 197, 94, 0.14); color: #86efac; border-color: rgba(34, 197, 94, 0.35); }
.chip.mock { background: rgba(245, 158, 11, 0.14); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }

/* ---------------- Section ---------------- */
.section {
  position: relative;
  background: rgba(30, 41, 59, 0.42);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 700; color: var(--txt-0); }
.section-sub { font-size: 12px; color: var(--txt-3); }
.layer-tag {
  position: absolute; top: -9px; left: 20px;
  padding: 2px 10px; border-radius: 20px; font-size: 10px; font-weight: 700;
  letter-spacing: 1px; background: linear-gradient(135deg, var(--brand-dk), var(--purple));
  color: #fff; box-shadow: 0 3px 10px rgba(99, 102, 241, 0.4);
}

/* ---------------- KPI ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.kpi {
  background: linear-gradient(160deg, rgba(39, 52, 73, 0.85), rgba(30, 41, 59, 0.7));
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px; transition: transform .18s, border-color .18s;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.kpi-label { font-size: 12px; color: var(--txt-2); margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--txt-0); line-height: 1.15; letter-spacing: -.5px; }
.kpi-value .unit { font-size: 14px; font-weight: 600; color: var(--txt-2); margin-left: 2px; }
.kpi-value.is-warn { color: var(--warn); }
.kpi-value.is-bad { color: var(--bad); }
.kpi-value.is-ok { color: var(--ok); }
.kpi-foot { font-size: 11px; color: var(--txt-3); margin-top: 5px; }

/* ---------------- Chart ---------------- */
.chart { width: 100%; height: 300px; margin-top: 16px; }
.chart.sm { height: 260px; }
.chart.lg { height: 340px; }

.notice {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; height: 100%; min-height: 180px; padding: 20px;
  color: var(--txt-3); font-size: 13px; text-align: center;
  background: rgba(15, 23, 42, 0.4); border: 1px dashed var(--line); border-radius: var(--radius-sm);
}
.notice .ico { font-size: 26px; opacity: .7; }
.notice small { color: #475569; font-size: 11px; }
.notice.warn { color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.06); }

.inline-warn {
  margin-top: 12px; padding: 9px 13px; border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d; font-size: 12px;
}

/* ---------------- Health ---------------- */
.health { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.health-gauge { width: 236px; height: 236px; flex: none; }
.health-factors { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 11px; }
.factor { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.factor-name { font-size: 12px; color: var(--txt-2); }
.factor-score { font-size: 13px; font-weight: 700; color: var(--txt-1); }
.factor-bar { grid-column: 1 / -1; height: 5px; background: rgba(148, 163, 184, 0.14); border-radius: 3px; overflow: hidden; }
.factor-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .6s ease; }

/* ---------------- Table ---------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 600;
  color: var(--txt-3); text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--line);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid rgba(99, 102, 241, 0.08); color: var(--txt-1); }
.tbl tbody tr:hover { background: rgba(99, 102, 241, 0.06); }
.tbl td.num { font-weight: 700; color: var(--brand-lt); }
.medal { font-size: 16px; }
.rank-no { color: var(--txt-3); font-weight: 600; }
.bar-cell { min-width: 120px; }
.bar-mini { height: 6px; background: rgba(148, 163, 184, 0.14); border-radius: 3px; overflow: hidden; }
.bar-mini > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--purple)); border-radius: 3px; }

/* ---------------- Suggestions ---------------- */
.tips {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.06));
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.tips h3 { font-size: 14px; color: #c7d2fe; margin-bottom: 10px; }
.tips ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.tips li { font-size: 13px; color: var(--txt-2); padding-left: 20px; position: relative; }
.tips li::before { content: '▸'; position: absolute; left: 4px; color: var(--brand-lt); }

.note { font-size: 11px; color: var(--txt-3); line-height: 1.9; }
.note b { color: var(--txt-2); }

/* ---------------- Footer ---------------- */
.footer {
  text-align: center; padding: 22px 16px; color: var(--txt-3); font-size: 12px;
  border-top: 1px solid var(--line); margin-top: 8px;
}

/* ---------------- Loading ---------------- */
.loader {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(11, 17, 32, 0.9); backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.loader-box { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 24px; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid rgba(99, 102, 241, 0.2); border-top-color: var(--brand);
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-txt { font-size: 13px; color: var(--txt-2); }
.loader-err { color: var(--bad); font-size: 14px; max-width: 380px; }

/* ---------------- Modal ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 9500; padding: 20px;
  background: rgba(11, 17, 32, 0.74); backdrop-filter: blur(5px);
  display: grid; place-items: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  width: 100%; max-width: 560px; max-height: 82vh;
  background: var(--bg-1); border: 1px solid var(--line-strong);
  border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes pop { from { transform: scale(.95) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box.wide { max-width: 640px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; background: linear-gradient(135deg, var(--brand-dk), var(--purple)); color: #fff;
}
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-x {
  width: 28px; height: 28px; flex: none; border: none; border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 14px;
  display: grid; place-items: center; transition: background .16s;
}
.modal-x:hover { background: rgba(255, 255, 255, 0.32); }
.modal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--txt-3);
}
.modal-body { padding: 14px 20px 20px; overflow-y: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 9px;
}

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--txt-2); margin-bottom: 6px; }
.input {
  width: 100%; padding: 9px 12px; font-size: 13px;
  background: var(--bg-2); color: var(--txt-1);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); outline: none;
  transition: border-color .18s;
}
.input:focus { border-color: var(--brand-lt); }
.form-hint { font-size: 11px; color: var(--txt-3); margin-top: 5px; }

/* mail list */
.mail-list { display: flex; flex-direction: column; gap: 9px; }
.mail-item {
  background: rgba(30, 41, 59, 0.66); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; transition: border-color .16s;
}
.mail-item:hover { border-color: var(--line-strong); }
.mail-subj { font-size: 13px; font-weight: 600; color: var(--txt-0); margin-bottom: 4px; word-break: break-word; }
.mail-meta { font-size: 11px; color: var(--txt-3); display: flex; gap: 8px; flex-wrap: wrap; }
.mail-prev { font-size: 12px; color: var(--txt-2); margin-top: 7px; max-height: 42px; overflow: hidden; word-break: break-word; }
.mail-clip { color: var(--warn); }

/* ---------------- Toast ---------------- */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 9800; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px;
  background: var(--bg-2); color: var(--txt-1); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); animation: slide .22s ease; max-width: 340px;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.ok { border-color: rgba(34, 197, 94, 0.45); }
.toast.err { border-color: rgba(239, 68, 68, 0.45); }

/* ---------------- Skeleton ---------------- */
.sk { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .health { justify-content: center; }
  .health-gauge { width: 200px; height: 200px; }
}
@media (max-width: 768px) {
  .wrap { padding: 16px 12px 36px; }
  .topbar-inner { padding: 10px 12px; gap: 10px; }
  .brand-txt h1 { font-size: 14px; }
  .brand-txt p { display: none; }
  .tool-group { width: 100%; justify-content: space-between; }
  .field label { display: none; }
  .select { min-width: 0; flex: 1; }
  .section { padding: 18px 14px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 23px; }
  .chart, .chart.sm, .chart.lg { height: 250px; }
  .modal { padding: 12px; }
  .modal-box { max-height: 88vh; }
  .btn span.txt { display: none; }
}
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .health-gauge { width: 180px; height: 180px; }
}
