/* 天眼云管。设计稿 ~/tianyan/design（cloud-*.png）：默认 B「明亮工作台」浅色、表格页为主；右上角可切 A「值守夜幕」深色。
   骨架：左侧导航 220 + 顶栏 56 + 页边距 20；卡片 1px 描边不用阴影，弹窗是唯一带投影的浮层。不引外网字体。 */
:root {
  --bg: #f3f5f7; --surface: #ffffff; --surface2: #f7f8fa; --line: #e3e7ec; --ink: #111827; --mute: #6b7280; --mute2: #9ca3af;
  --accent: #0b7a5c; --accent-ink: #ffffff; --accent-bg: #e3f1ec; --nav-on: #e3f1ec;
  --crit: #d92d20; --crit-bg: #fdeceb; --warn: #dc6803; --warn-bg: #fdf0e3; --minor: #b88704; --minor-bg: #faf3dc;
  --info: #2563eb; --info-bg: #e8effd; --ok: #16a34a; --ok-bg: #e7f6ec; --idle: #94a3b8;
  --bar: #3b6fd8; --shadow: 0 12px 40px rgba(17, 24, 39, .18); --mask: rgba(17, 24, 39, .4);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side: 220px; --pad: 20px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", Inter, "Segoe UI", sans-serif;
}
:root.dark {
  --bg: #0a0e13; --surface: #11161d; --surface2: #171e27; --line: #212a35; --ink: #e7ecf2; --mute: #6f7c8c; --mute2: #4d5866;
  --accent: #3b8cff; --accent-ink: #ffffff; --accent-bg: #13233b; --nav-on: #16253b;
  --crit: #f0443a; --crit-bg: #2a1416; --warn: #f5880b; --warn-bg: #2a1c0d; --minor: #e8b90e; --minor-bg: #29240c;
  --info: #3b8cff; --info-bg: #13233b; --ok: #22c55e; --ok-bg: #0f2a1a; --idle: #64748b;
  --bar: #2d5da8; --shadow: 0 12px 40px rgba(0, 0, 0, .6); --mask: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.muted { color: var(--mute); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.crit-t { color: var(--crit); } .warn-t { color: var(--warn); } .minor-t { color: var(--minor); } .info-t { color: var(--info); } .ok-t { color: var(--ok); }

/* ---------- 骨架 ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side); flex: 0 0 var(--side); background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: 0 0 auto; }
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand span { display: block; font-size: 11px; color: var(--mute); }
.nav a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 8px; color: var(--ink); margin-bottom: 4px; font-size: 14px; }
.nav a svg.i { color: var(--mute); }
.nav a:hover { background: var(--surface2); text-decoration: none; }
.nav a.on { background: var(--nav-on); color: var(--accent); font-weight: 600; }
.nav a.on svg.i { color: var(--accent); }
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 var(--pad); background: var(--bg);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.top h1 { font-size: 18px; margin: 0; font-weight: 700; white-space: nowrap; }
.top .sub { color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top .grow { flex: 1 1 auto; }
.top select { height: 34px; }
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; }
.who .av { width: 28px; height: 28px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.who a { color: var(--mute); }
.iconbtn { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.content { padding: var(--pad); flex: 1 1 auto; min-width: 0; }

/* ---------- 卡片 / 表格 ---------- */
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; min-width: 0; }
.kpi .l { color: var(--mute); font-size: 13px; }
.kpi .n { font-size: 30px; font-weight: 700; line-height: 1.25; margin: 4px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .s { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel h2 { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .aside { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--mute); }
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0 12px; height: 52px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
th { height: 40px; color: var(--mute); font-weight: 400; font-size: 13px; background: var(--surface2); }
tr:last-child td { border-bottom: 0; }
td.b, td b { font-weight: 600; }
td.wrap { white-space: normal; min-width: 200px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface2); }
.panel:not(.flush) table th, .panel:not(.flush) table td { padding-left: 8px; padding-right: 8px; }
.panel:not(.flush) table th:first-child, .panel:not(.flush) table td:first-child { padding-left: 0; }
.panel:not(.flush) table th { background: transparent; }
.empty { color: var(--mute); padding: 28px 0; text-align: center; }

/* 状态圆点 + 标签 */
.dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--idle); flex: 0 0 auto; }
.dot.online::before, .dot.ok::before { background: var(--ok); } .dot.offline::before, .dot.crit::before { background: var(--crit); }
.dot.warn::before { background: var(--warn); } .dot.minor::before { background: var(--minor); } .dot.info::before { background: var(--info); }
.dot.online, .dot.ok.t { color: var(--ok); } .dot.offline, .dot.crit.t { color: var(--crit); } .dot.warn.t { color: var(--warn); }
.dot.minor.t { color: var(--minor); } .dot.info.t { color: var(--info); } .dot.idle.t, .dot.never, .dot.disabled { color: var(--mute); }
.dot.online { color: var(--ink); }
.badge { display: inline-block; padding: 0 7px; line-height: 20px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--surface2); color: var(--mute); margin-right: 4px; white-space: nowrap; }
.badge.crit { background: var(--crit-bg); color: var(--crit); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.minor { background: var(--minor-bg); color: var(--minor); } .badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.info { background: var(--info-bg); color: var(--info); }
.badge.off { text-decoration: line-through; }

/* 按钮 / 输入 */
button, .btn {
  font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); height: 32px; padding: 0 12px;
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; vertical-align: middle;
}
button:hover, .btn:hover { background: var(--surface2); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); background: var(--accent); }
button.danger { color: var(--crit); }
button.sm { height: 28px; padding: 0 10px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button + button, .btn + button, button + .btn { margin-left: 6px; }
td button + button { margin-left: 6px; }
input, select, textarea { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; height: 34px; background: var(--surface); color: var(--ink); max-width: 100%; }
textarea { height: auto; padding: 8px 10px; }
select[multiple] { height: auto; padding: 4px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { height: auto; accent-color: var(--accent); }
input[type=file] { height: auto; padding: 4px; border-style: dashed; color: var(--mute); }
input[type=file]::file-selector-button { font: inherit; font-size: 13px; height: 26px; margin-right: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface2); color: var(--ink); padding: 0 10px; cursor: pointer; }
.search { position: relative; }
.search svg.i { position: absolute; left: 10px; top: 9px; color: var(--mute); }
.search input { padding-left: 32px; width: 270px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 auto; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; }
.chip.on { background: var(--nav-on); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.form { display: grid; gap: 10px; grid-template-columns: 110px 1fr; align-items: center; }
.form label { color: var(--mute); }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; }
.kv > div:nth-child(odd) { color: var(--mute); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); margin-bottom: 16px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.notice svg.i { color: var(--mute); margin-top: 2px; }
.notice.warn { background: var(--warn-bg); border-color: transparent; }
.notice.crit { background: var(--crit-bg); border-color: transparent; color: var(--crit); }
.bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; min-width: 60px; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.warn > i { background: var(--warn); } .bar.crit > i { background: var(--crit); }
.progress { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; margin: 14px 0 10px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.cams { display: flex; flex-wrap: wrap; gap: 6px; }
.cam { border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.cam.off { border-color: transparent; background: var(--crit-bg); color: var(--crit); }
pre.log { background: #0f1720; color: #d6e2f0; padding: 12px; border-radius: 8px; max-height: 60vh; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); }

/* 概览：右侧设备告警卡片 + 柱状图 */
.alist { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.stack > * { min-width: 0; }
.att { display: inline-block; max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.aitem { display: block; background: var(--surface2); border-radius: 8px; padding: 10px 12px; min-width: 0; overflow: hidden; color: inherit; }
.aitem:hover { text-decoration: none; filter: brightness(.98); }
.aitem .t { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.aitem .t span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aitem .s { display: flex; gap: 8px; font-size: 12px; color: var(--mute); margin-top: 4px; }
.aitem .s .m { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aitem .s .r { color: var(--ink); white-space: nowrap; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--mute); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--mute); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; }

/* 版本与升级：发布卡片 */
.rcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.rcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; min-width: 0; }
.rcard.on { border-color: var(--accent); }
.rcard .h { display: flex; align-items: baseline; gap: 10px; }
.rcard .h b { font-size: 18px; }
.rcard .h .mono { color: var(--mute); font-size: 12px; }
.rcard .d { margin-top: 6px; font-size: 13px; }
.rcard .st { font-size: 12px; color: var(--mute); margin-bottom: 12px; }

/* 账号与角色：权限矩阵 */
.matrix th, .matrix td { height: 46px; text-align: center; padding: 0 4px; font-size: 13px; }
.matrix th { font-size: 11px; white-space: normal; line-height: 1.3; word-break: keep-all; }
.matrix th:first-child, .matrix td:first-child { text-align: left; padding-left: 0; }
.matrix .y { color: var(--ok); } .matrix .n { color: var(--mute2); }
.secbox { background: var(--surface2); border-radius: 8px; padding: 12px 14px; font-size: 12px; color: var(--mute); margin-top: 12px; }
.secbox b { display: block; color: var(--ink); font-size: 13px; margin-bottom: 4px; }

/* 弹窗 / 提示 / 登录 */
.modal-bg { position: fixed; inset: 0; background: var(--mask); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 20; overflow: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(860px, 100%); padding: 18px 22px; box-shadow: var(--shadow); }
.modal h2 { display: flex; justify-content: space-between; align-items: center; font-size: 16px; margin: 0 0 14px; }
.modal h2 a { font-size: 13px; font-weight: 400; color: var(--mute); }
.modal .actions { margin-top: 16px; text-align: right; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; z-index: 30; max-width: 420px; box-shadow: var(--shadow); }
.toast.err { background: var(--crit); color: #fff; }
.checklist { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.checklist label { display: flex; gap: 8px; padding: 5px 0; align-items: center; }
.login { max-width: 380px; margin: 14vh auto; padding: 0 16px; }
.login .panel { padding: 28px; }
.login .logo { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; margin-bottom: 16px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login input { width: 100%; margin-bottom: 12px; height: 40px; }
.login button { width: 100%; height: 40px; justify-content: center; font-size: 14px; }
.subnav { display: flex; gap: 16px; font-size: 13px; margin: -4px 0 14px; }
.subnav a { color: var(--mute); } .subnav a.on { color: var(--accent); font-weight: 600; }

/* 1366 宽：导航变窄、页边距 16、KPI 数字 26、次要列隐藏 */
@media (max-width: 1500px) {
  :root { --side: 188px; --pad: 16px; }
  .kpis { gap: 12px; } .kpi { padding: 14px 16px; } .kpi .n { font-size: 26px; }
  .split { grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; }
  th, td { padding: 0 8px; height: 48px; }
  th:first-child, td:first-child { padding-left: 14px; } th:last-child, td:last-child { padding-right: 14px; }
  .hide-sm { display: none; }
  .search input { width: 210px; }
  .att { max-width: 300px; }
  .split.users { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .split, .rcards { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .side { position: static; width: auto; height: auto; display: flex; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 10px 0 0; } .brand span { display: none; }
  .nav { display: flex; gap: 4px; } .nav a { margin: 0; white-space: nowrap; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .form, .kv { grid-template-columns: 1fr; }
  .top .sub { display: none; }
}
