/* ============================================================
   设备维保统计大屏 · 视觉样式
   深色科技风 / 玻璃拟态 / 渐变高光
   ============================================================ */
:root {
  --bg-0: #04091a;
  --bg-1: #0a1730;
  --panel-1: rgba(20, 38, 66, .86);
  --panel-2: rgba(11, 23, 44, .88);
  --stroke: rgba(96, 165, 250, .16);
  --stroke-strong: rgba(96, 165, 250, .42);
  --text: #eaf2ff;
  --muted: #93a7c4;
  --blue: #38bdf8;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --radius: 14px;
  --shadow: 0 12px 34px rgba(1, 8, 22, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  background:
    radial-gradient(900px 520px at 18% -8%, rgba(56, 189, 248, .18), transparent 62%),
    radial-gradient(820px 560px at 86% -4%, rgba(167, 139, 250, .16), transparent 60%),
    radial-gradient(760px 520px at 50% 112%, rgba(34, 211, 238, .10), transparent 62%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
}

/* 背景细网格 + 光斑 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(96, 165, 250, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 165, 250, .05) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(1200px 700px at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(1200px 700px at 50% 0%, #000 0%, transparent 78%);
  z-index: 0;
}

.screen { position: relative; z-index: 1; max-width: 1920px; margin: 0 auto; padding: 14px 24px 28px; }

/* ---------- 顶部标题栏 ---------- */
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 8px 6px 16px;
  margin-bottom: 18px;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, .55) 20%, rgba(34, 211, 238, .55) 80%, transparent);
  opacity: .8;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center; border-radius: 13px;
  color: #04121f;
  background: linear-gradient(140deg, var(--cyan), var(--blue) 55%, var(--violet));
  box-shadow: 0 8px 22px rgba(34, 211, 238, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.brand .logo svg { width: 24px; height: 24px; }
.brand h1 {
  font-size: 26px; margin: 0; letter-spacing: 4px; font-weight: 800;
  background: linear-gradient(90deg, #ffffff, #bcd8ff 55%, #7dd3fc);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub { color: var(--muted); font-size: 12px; letter-spacing: 1.4px; margin-top: 4px; }
.mode-chip {
  display: none; margin-left: 6px; padding: 3px 11px; border-radius: 20px;
  font-size: 12px; letter-spacing: .5px; color: #fcd34d;
  background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .45);
}
body.demo-mode .mode-chip { display: inline-block; }

.tools { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.tools .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.tools .meta .t1 { color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.tools #updated { color: #a9bdd9; font-size: 12px; }
.clock {
  font-family: "DIN Alternate", "Segoe UI", monospace;
  font-size: 15px; font-weight: 700; letter-spacing: 1px; color: #cfe6ff;
}

.btn {
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(180deg, rgba(56, 189, 248, .16), rgba(56, 189, 248, .06));
  color: #bfe6ff; padding: 8px 16px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 500; letter-spacing: .5px; transition: .2s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.btn:hover { background: rgba(56, 189, 248, .24); color: #eaf7ff; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #04121f; font-weight: 700; border: none;
  box-shadow: 0 8px 20px rgba(34, 211, 238, .32);
}
.btn.ghost { color: var(--muted); border-color: rgba(147, 167, 196, .28); background: transparent; }
.btn.ghost:hover { color: #d4e3f7; border-color: rgba(147, 167, 196, .5); }

/* 数据模式切换 */
.seg {
  display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px;
  background: rgba(147, 167, 196, .1); border: 1px solid var(--stroke);
}
.seg-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 6px 14px; border-radius: 8px; transition: .2s;
  letter-spacing: .5px; white-space: nowrap;
}
.seg-btn:hover { color: #d4e3f7; }
.seg-btn.active {
  color: #04121f; font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 4px 12px rgba(34, 211, 238, .3);
}
.btn[disabled] { opacity: .85; cursor: default; transform: none; }
.btn .spin {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(191, 230, 255, .35); border-top-color: #bfe6ff;
  animation: spin .7s linear infinite; margin-right: 7px; vertical-align: -2px;
}

/* ---------- KPI 卡片 ---------- */
.kpis { display: grid; gap: 14px; margin-bottom: 16px; grid-template-columns: repeat(8, 1fr); }
.kpi {
  --k: var(--blue);
  position: relative; overflow: hidden;
  padding: 16px 18px; border-radius: 16px; min-height: 100px;
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(160deg, var(--panel-1), var(--panel-2));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  animation: rise .5s ease both;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--k), transparent 72%);
}
.kpi::after {
  content: ""; position: absolute; right: -40px; top: -50px; width: 130px; height: 130px;
  border-radius: 50%; background: radial-gradient(circle, var(--k), transparent 68%);
  opacity: .16; pointer-events: none;
}
.kpi:hover { transform: translateY(-3px); border-color: var(--stroke-strong); box-shadow: 0 18px 40px rgba(1, 8, 22, .55); }

.kpi .ic {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center;
  color: var(--k);
}
.kpi .ic svg { width: 30px; height: 30px; }
.kpi .kpi-main {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 6px; text-align: left;
}
.kpi .label { color: #a9bdd9; font-size: 13px; letter-spacing: .3px; }
.kpi .value {
  font-size: 30px; font-weight: 800; line-height: 1.05; color: var(--k);
  font-family: "DIN Alternate", "Segoe UI", system-ui, sans-serif;
  text-shadow: 0 0 22px color-mix(in srgb, var(--k) 40%, transparent);
}
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; text-shadow: none; }
.kpi .value .frac { font-size: 13px; font-weight: 600; color: #a9bdd9; margin-left: 6px; text-shadow: none; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 7px; }

/* 加载骨架 */
.kpi.sk { display: block; pointer-events: none; }
.sk-line {
  display: block; height: 12px; border-radius: 6px; margin-bottom: 10px;
  background: linear-gradient(90deg, rgba(147, 167, 196, .12) 25%, rgba(147, 167, 196, .26) 37%, rgba(147, 167, 196, .12) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.sk-line.lg { height: 26px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.kpi.cyan   { --k: var(--cyan); }
.kpi.blue   { --k: var(--blue); }
.kpi.green  { --k: var(--ok); }
.kpi.amber  { --k: var(--warn); }
.kpi.red    { --k: var(--danger); }
.kpi.violet { --k: var(--violet); }

/* ---------- 图表布局 ---------- */
.grid-charts { display: grid; gap: 14px; margin-bottom: 16px; grid-template-columns: 1.1fr 1.1fr 1fr; }
.grid-wide { display: grid; gap: 14px; grid-template-columns: 1.6fr 1fr; margin-bottom: 16px; }
.grid-bottom { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 38, 66, .82), rgba(11, 23, 44, .84));
  border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 15px 17px 12px; box-shadow: var(--shadow);
  min-width: 0; transition: border-color .22s ease;
  animation: rise .5s ease both;
}
.panel::before {
  content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, .65), transparent);
  opacity: .85;
}
.panel:hover { border-color: var(--stroke-strong); }
.panel h2 {
  font-size: 15px; margin: 0 0 10px; font-weight: 600; color: #d7e6fb;
  display: flex; align-items: center; gap: 9px; letter-spacing: .4px;
}
.panel h2::before {
  content: ""; width: 4px; height: 15px; border-radius: 3px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
  box-shadow: 0 0 12px rgba(34, 211, 238, .6);
}
.chart { width: 100%; height: 240px; }
.chart.tall { height: 300px; }

/* ---------- 列表 / 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid rgba(147, 167, 196, .12); }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .5px; }
.tbl td { color: #d5e3f5; }
.tbl tbody tr { transition: background .16s ease; }
.tbl tbody tr:hover { background: rgba(96, 165, 250, .07); }
.tbl tr:last-child td { border-bottom: none; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; border: 1px solid transparent; }
.tag.miss { color: #fda4af; border-color: rgba(251, 113, 133, .5); background: rgba(251, 113, 133, .12); }
.tag.over { color: #fcd34d; border-color: rgba(251, 191, 36, .5); background: rgba(251, 191, 36, .12); }

.rank { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.rank:last-child { margin-bottom: 2px; }
.rank .no {
  width: 22px; height: 22px; flex: none; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; background: rgba(96, 165, 250, .16); color: #9cc6f5;
  border: 1px solid rgba(96, 165, 250, .25);
}
.rank .no.top { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #04121f; border: none; font-weight: 800; }
.rank .nm { width: 96px; color: #d5e3f5; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .bar { flex: 1; height: 9px; border-radius: 6px; background: rgba(147, 167, 196, .14); overflow: hidden; }
.rank .bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--cyan)); box-shadow: 0 0 12px rgba(34, 211, 238, .5); }
.rank .vl { width: 44px; text-align: right; color: #7fe3f5; font-size: 13px; font-weight: 600; }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 0; }

/* ---------- 授权遮罩 ---------- */
.mask {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(4, 10, 20, .82); backdrop-filter: blur(7px); z-index: 50;
}
.mask.show { display: flex; }
.mask .box {
  width: 460px; max-width: 92vw; text-align: center; padding: 42px 36px;
  background: linear-gradient(180deg, rgba(20, 38, 66, .96), rgba(11, 23, 44, .98));
  border: 1px solid var(--stroke-strong); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .62);
}
.mask .box .ic { font-size: 46px; }
.mask .box h3 { margin: 14px 0 8px; font-size: 20px; }
.mask .box p { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 0 0 24px; }

.loading { position: fixed; right: 24px; bottom: 22px; color: var(--muted); font-size: 13px; display: none; }
.loading.show { display: block; }
.loading i {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(147, 167, 196, .3); border-top-color: var(--cyan);
  animation: spin .7s linear infinite; margin-right: 8px; vertical-align: -1px;
  box-shadow: 0 0 10px rgba(34, 211, 238, .45);
}

@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 卡片入场错峰 */
.kpis .kpi:nth-child(1) { animation-delay: .02s; }
.kpis .kpi:nth-child(2) { animation-delay: .06s; }
.kpis .kpi:nth-child(3) { animation-delay: .10s; }
.kpis .kpi:nth-child(4) { animation-delay: .14s; }
.kpis .kpi:nth-child(5) { animation-delay: .18s; }
.kpis .kpi:nth-child(6) { animation-delay: .22s; }
.kpis .kpi:nth-child(7) { animation-delay: .26s; }
.kpis .kpi:nth-child(8) { animation-delay: .30s; }
.grid-charts .panel:nth-child(2) { animation-delay: .06s; }
.grid-charts .panel:nth-child(3) { animation-delay: .12s; }
.grid-wide .panel:nth-child(2) { animation-delay: .06s; }

@media (max-width: 1500px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1180px) {
  .grid-charts, .grid-wide, .grid-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .brand h1 { font-size: 18px; letter-spacing: 1px; }
  .brand .logo { width: 38px; height: 38px; }
  .tools .meta { display: none; }
  .seg-btn { padding: 6px 10px; font-size: 12px; }
  .chart { height: 210px; }
  .chart.tall { height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .kpi, .panel { animation: none; }
}
