:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --ink-soft: #5b6675;
  --line: #e6eaf2;
  --primary: #2f6bff;
  --primary-soft: #eaf1ff;
  --teal: #12b886;
  --warn: #f59f00;
  --danger: #e03131;
  --purple: #7048e8;
  --shadow: 0 2px 12px rgba(31, 39, 51, 0.06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #11192b; color: #c8d2e0; display: flex; flex-direction: column; padding: 18px 12px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg,#2f6bff,#12b886); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; }
.brand .name { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.2; }
.brand .sub { font-size: 11px; color: #7c8aa0; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #aab6c8; font-size: 13.5px; transition: .15s; cursor: pointer; }
.nav a:hover { background: #1c2740; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ic { width: 18px; text-align: center; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; }
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--ink-soft); }
.topbar .user { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 22px; overflow: auto; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-h { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.panel-b { padding: 18px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card-kpi .label { color: var(--ink-soft); font-size: 12.5px; }
.card-kpi .val { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card-kpi .delta { font-size: 12px; color: var(--teal); margin-top: 4px; }

.row2 { grid-template-columns: 1.4fr 1fr; }
.row2b { grid-template-columns: 1fr 1fr; }
@media (max-width: 980px){ .row2,.row2b { grid-template-columns: 1fr; } .sidebar{display:none;} }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; background: #fafbfe; }
tbody tr:hover { background: #f8faff; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.b-P0 { background: #ffe3e3; color: var(--danger); }
.b-P1 { background: #fff3bf; color: #b08900; }
.b-P2 { background: #e7f5ff; color: #1971c2; }
.b-P3 { background: #e6fcf5; color: #099268; }
.b-ok { background: #e6fcf5; color: #099268; }
.b-warn { background: #fff3bf; color: #b08900; }
.b-danger { background: #ffe3e3; color: var(--danger); }
.b-info { background: #e7f5ff; color: #1971c2; }
.b-muted { background: #f1f3f5; color: #868e96; }
.b-progress { background: #eef2ff; color: #4263eb; }
.b-pending { background: #fff9db; color: #f08c00; }
.b-resolved { background: #ebfbee; color: #2b8a3e; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.05); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.tag { font-size: 12px; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#0f1b34,#1c3a6e 60%,#12b886); }
.login-box { width: 380px; background: #fff; border-radius: 16px; padding: 34px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-box h1 { font-size: 19px; margin: 0 0 4px; }
.login-box .sub { color: var(--ink-soft); margin-bottom: 22px; font-size: 13px; }
.login-box input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.login-box .err { color: var(--danger); font-size: 12.5px; margin-bottom: 10px; }
.login-box .hint { margin-top: 16px; font-size: 12px; color: var(--ink-soft); line-height: 1.7; }

.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; } .gap { gap: 10px; }
.nowrap { white-space: nowrap; }
.chart-box { position: relative; height: 280px; }

.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; justify-content: flex-end; z-index: 50; }
.drawer { width: 560px; max-width: 92vw; background: #fff; height: 100%; overflow: auto; padding: 20px 24px; }
.drawer h3 { margin: 0 0 14px; }
.close-x { cursor: pointer; color: var(--ink-soft); font-size: 20px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; }
.field select, .field input, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: inherit; }
.field textarea { resize: vertical; }

.kpi-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.scroll-x { overflow-x: auto; }
.bar { height: 8px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; }
.center-msg { display:flex; align-items:center; justify-content:center; height:100%; color: var(--ink-soft); }

/* 全生命周期 / 设备档案 网格 */
.life-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin: 6px 0 14px; }
.life-grid > div { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.life-grid .muted { display: block; font-size: 11.5px; margin-bottom: 4px; }
.life-grid b { font-size: 14px; }

/* 工单全过程时间轴 */
.timeline { margin: 6px 0 4px; }
.tl-item { position: relative; padding: 0 0 18px 26px; }
.tl-item:before { content: ""; position: absolute; left: 7px; top: 16px; bottom: -2px; width: 2px; background: var(--line); }
.tl-item:last-child:before { display: none; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--line); }
.tl-item.done .tl-dot { background: var(--primary); border-color: var(--primary); }
.tl-item b { font-size: 13.5px; }
.tl-item .muted { font-size: 12px; }

/* 多租户上下文 UI */
.tag-tenant { background: var(--primary-soft); color: var(--primary); padding: 3px 11px; border-radius: 20px; font-weight: 600; }
.tenant-welcome { background: linear-gradient(90deg, #eaf1ff, #e6fcf5); border: 1px solid #dbe4ff; border-radius: var(--radius); padding: 12px 18px; margin-bottom: 16px; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.tenant-welcome b { font-size: 15px; color: var(--primary); }
.tenant-welcome span { color: var(--ink-soft); }
