:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1d2433;
  --ink-2: #5b6577;
  --ink-3: #8b94a5;
  --line: #e4e8ef;
  --brand: #2f6fed;
  --brand-soft: #e8f0fe;
  --green: #12a97a;
  --green-soft: #e3f7f0;
  --amber: #d98a00;
  --amber-soft: #fdf3e0;
  --red: #dd4b4b;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* 本页多处用 hidden 属性做显隐；一旦元素自身设了 display（flex/grid），
   会盖掉浏览器默认的 [hidden]{display:none}，导致「藏不住」。统一兜一层。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

h1, h2 { margin: 0; font-weight: 650; }
small { font-weight: 400; }

button, input, select, a.ghost { font: inherit; }

button, a.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, a.ghost:hover { border-color: #c9d3e4; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.ghost { background: transparent; }

input, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--brand); }

/* ── 登录 ───────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #eef3ff 0%, #f7f9fc 60%, #eef7f2 100%);
}
.login-card {
  width: 330px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: 0 16px 40px rgba(29, 36, 51, .08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { font-size: 20px; }
.login-card .sub { margin: -6px 0 6px; color: var(--ink-3); font-size: 13px; }
.login-card button { background: var(--brand); border-color: var(--brand); color: #fff; padding: 9px; }
.err { color: var(--red); font-size: 13px; margin: 0; }

/* ── 顶栏 ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 650; display: flex; align-items: baseline; gap: 10px; }
.brand small { color: var(--ink-3); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.days-label { color: var(--ink-2); display: flex; align-items: center; gap: 6px; }

main { padding: 20px 22px 60px; max-width: 1180px; margin: 0 auto; }

/* ── 数据卡 ─────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .k { color: var(--ink-3); font-size: 12.5px; }
.card .v { font-size: 25px; font-weight: 660; margin-top: 4px; letter-spacing: -.4px; }
.card .h { color: var(--ink-3); font-size: 12px; margin-top: 2px; min-height: 17px; }

/* ── 面板 ───────────────────────────────────────────────── */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px 16px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 10px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tools input[type="search"] { width: 200px; }
.legend { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot.active { background: var(--brand); }
.dot.new { background: var(--green); }
.legend .line { width: 16px; height: 2px; background: var(--amber); display: inline-block; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid .panel { margin-bottom: 16px; }

/* ── 图表 ───────────────────────────────────────────────── */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.empty { color: var(--ink-3); text-align: center; padding: 34px 0; margin: 0; }

/* ── 表格 ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-3); font-weight: 550; font-size: 12.5px; }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafd; }
tbody tr.excluded { color: var(--ink-3); text-decoration: line-through; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--brand-soft);
  color: var(--brand);
}
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.mute { background: #eef0f4; color: var(--ink-3); }

.pager { display: flex; align-items: center; gap: 10px; padding-top: 12px; color: var(--ink-2); }
.pager .spacer { flex: 1; }

/* ── 分布 ───────────────────────────────────────────────── */
.dist { list-style: none; margin: 0; padding: 0; }
.dist li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.dist li:last-child { border-bottom: 0; }
.dist .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.dist .bar { height: 6px; border-radius: 3px; background: var(--brand-soft); margin-top: 5px; overflow: hidden; }
.dist .bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* ── 抽屉 ───────────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(560px, 100%);
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(29, 36, 51, .12);
  z-index: 40;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 15px; }
.drawer-body { padding: 16px 18px 40px; overflow-y: auto; }
.mask { position: fixed; inset: 0; background: rgba(20, 26, 38, .35); z-index: 30; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 16px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-all; }

.calendar { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; margin-bottom: 18px; }
.calendar i { aspect-ratio: 1 / 1; border-radius: 3px; background: #eef0f4; }
.calendar i[data-n="1"] { background: #c3d8fb; }
.calendar i[data-n="2"] { background: #8fb6f7; }
.calendar i[data-n="3"] { background: #5b93f0; }
.calendar i[data-n="9"] { background: var(--brand); }

h3.sec { font-size: 13px; color: var(--ink-2); margin: 0 0 8px; font-weight: 600; }
.logs { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.logs li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.logs li span:last-child { color: var(--ink-3); font-family: ui-monospace, Menlo, Consolas, monospace; }
.drawer-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
