:root {
  --bg: #050506;
  --panel: #141820;
  --panel-2: #0b0e14;
  --line: #2a3344;
  --text: #f1f3f5;
  --muted: #8a919b;
  --accent: #0052d9;
  --accent-soft: #4589ff;
  --ok: #2ba471;
  --warn: #f0c14b;
  --bad: #ff6b6b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}
a { color: var(--accent-soft); text-decoration: none; }
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: #050506;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  line-height: 1.15;
}
.brand span {
  color: var(--muted);
  font-weight: 400;
  margin-left: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
}
.nav {
  display: flex;
  gap: 18px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.summary {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
.kpi {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border: 0;
  border-radius: 0;
  background: #141820;
  color: var(--muted);
  font-size: 12px;
}
.kpi b {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.clock {
  color: var(--text);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  padding: 0 4px 0 8px;
  border-left: 1px solid var(--line);
}
.nav-link {
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border: 0;
  border-radius: 0;
  background: #141820;
}
.nav-link:hover {
  color: var(--accent-soft);
  background: #1b2230;
}
.nav-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #141820;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
.nav-switch.on { color: var(--text); }
.nav-switch-track {
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: #2a3344;
  position: relative;
  flex-shrink: 0;
}
.nav-switch.on .nav-switch-track { background: var(--accent); }
.nav-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d7dde6;
  transition: transform 0.16s ease;
}
.nav-switch.on .nav-switch-knob { transform: translateX(12px); }
.nav-switch .short { display: none; }
.wrap { padding: 22px 28px 40px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
input, button {
  font: inherit;
  color: var(--text);
}
input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
}
input:focus { border-color: var(--accent); }
button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
button.danger { background: #8a2d2d; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.nav-link .short { display: none; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}
.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #171c28 0%, #10141d 100%);
  border: 2px solid #2a3650;
  border-radius: 18px;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.card.idle {
  opacity: 0.46;
  filter: saturate(0.25) brightness(0.78);
  border-color: #1c2433;
  box-shadow: none;
}
.card.idle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(8, 10, 14, 0.28);
  backdrop-filter: blur(2.4px);
  pointer-events: none;
}
.card.idle .alarm-track { animation-play-state: paused; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.remark-box {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}
.alarm-flag {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bad);
  flex-shrink: 0;
  cursor: pointer;
}
.alarm-flag[hidden] { display: none; }
.alarm-pop,
.ver-pop {
  position: absolute;
  z-index: 4;
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  max-height: 6.4em;
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1.2, 0.32, 1), visibility 0.28s;
}
.alarm-pop {
  left: 16px;
  right: 16px;
  top: auto;
  bottom: 40px;
  background: #1a1014;
  border: 1px solid rgba(255, 107, 107, 0.38);
  color: var(--bad);
  transform-origin: 8px 100%;
  transform: translateY(8px) scale(0.92);
}
.ver-pop {
  right: 12px;
  bottom: 40px;
  left: auto;
  min-width: 148px;
  max-width: calc(100% - 32px);
  background: #1c2433;
  border: 1px solid #3a465c;
  color: var(--text);
  transform-origin: 100% 100%;
  transform: translateY(8px) scale(0.92);
}
.ver-pop small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.ver-pop b {
  display: block;
  font-weight: 600;
  font-size: 12px;
  word-break: break-all;
}
.card.alarm-open .alarm-pop,
.card.ver-open .ver-pop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.alarm-pop[hidden],
.ver-pop[hidden] { display: none; }
.alarm {
  flex: 0 1 30%;
  min-width: 72px;
  max-width: 120px;
  height: 1.35em;
  overflow: hidden;
  color: var(--bad);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35em;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
}
.alarm-track {
  display: inline-flex;
  width: max-content;
  will-change: transform;
  animation: alarm-scroll linear infinite;
}
.alarm-track span {
  padding-right: 2.4em;
  white-space: nowrap;
}
@keyframes alarm-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .alarm-track { animation: none; }
  .alarm-pop,
  .ver-pop { transition: none; }
}
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}
.pill.on { background: rgba(61, 214, 140, 0.16); color: var(--ok); }
.pill.off { background: rgba(139, 154, 171, 0.16); color: var(--muted); }
.pill.wait { background: rgba(245, 200, 76, 0.16); color: var(--warn); }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(61, 214, 140, 0.22);
}
.dot.off { background: var(--muted); }
.dot.wait { background: var(--warn); }
.name { font-size: 18px; font-weight: 700; }
.remark { color: var(--muted); font-size: 12px; margin-top: 4px; }
.grid .card .remark {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  margin-top: 0;
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grid .card .remark.empty { color: var(--muted); }
.remark-edit {
  width: 100%;
  min-width: 96px;
  max-width: 240px;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
}
.remark-edit:hover,
.remark-edit:focus {
  background: var(--panel-2);
  border-color: var(--line);
}
.remark-edit:focus { border-color: var(--accent); }
.remark-edit::placeholder { color: var(--muted); }
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.stat {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid #1c2433;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 58px;
}
.stat b {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.04em;
}
.stat.panel-stat {
  position: relative;
  overflow: hidden;
  padding-bottom: 28px;
}
.stat.panel-stat b { position: relative; z-index: 1; }
.stat b.metric {
  display: flex;
  align-items: flex-start;
  height: 1em;
  line-height: 1;
}
.metric.tick {
  animation: metric-jump 0.48s cubic-bezier(0.22, 0.8, 0.28, 1);
}
@keyframes metric-jump {
  0% { transform: translateY(0.32em); opacity: 0.4; }
  58% { transform: translateY(-0.1em); opacity: 1; }
  100% { transform: translateY(0); }
}
.metric .d {
  display: block;
  position: relative;
  width: 0.64em;
  height: 1em;
  overflow: hidden;
}
.metric .d i {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  font-style: normal;
  font-weight: 700;
  will-change: transform;
}
.metric .d i span {
  display: block;
  width: 0.64em;
  height: 1em;
  line-height: 1em;
  text-align: center;
}
.metric .sep {
  display: block;
  line-height: 1em;
}
.spark {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 22px;
  width: auto;
  display: block;
  pointer-events: none;
}
.hour-cap {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid #1c2433;
  border-radius: 10px;
  padding: 8px 10px 10px;
}
.hour-cap-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.hour-cap-head small { color: var(--muted); }
.hour-cap-head b { font-size: 20px; font-variant-numeric: tabular-nums; }
.hour-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 72px;
  overflow: visible;
}
.hour-bars .hb {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.hour-bars .hb i {
  position: relative;
  width: 100%;
  background: #2a3344;
  border-radius: 2px 2px 0 0;
  display: block;
}
.hour-bars .hb.on i { background: var(--accent-soft); }
.hour-bars .hb em {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1px);
  transform: translateX(-50%);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.4px;
  color: #d7dde6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.hour-bars .hb:nth-child(even) em {
  bottom: calc(100% + 9px);
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
}
.card-foot .alarm-flag { margin-right: auto; }
.card-foot [data-k="seen"] {
  flex-shrink: 0;
  margin-left: auto;
  cursor: pointer;
}
.card-foot [data-k="seen"]:hover { color: var(--text); }
.empty {
  color: var(--muted);
  padding: 40px 8px;
  text-align: center;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
th { color: var(--muted); font-weight: 600; }
.err { color: var(--bad); min-height: 20px; font-size: 13px; }
.ok { color: var(--ok); }
.login-box {
  max-width: 360px;
  margin: 80px auto;
}
@media (max-width: 720px) {
  .top {
    gap: 8px;
    padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-top: max(8px, env(safe-area-inset-top));
    align-items: center;
  }
  .brand {
    font-size: 15px;
    letter-spacing: 0.02em;
    padding-left: 8px;
    gap: 0;
    min-width: 0;
    flex: 0 1 auto;
    white-space: nowrap;
  }
  .brand span { display: none; }
  .nav {
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
    white-space: nowrap;
  }
  .summary { gap: 4px; }
  .kpi {
    gap: 4px;
    padding: 2px 7px;
    font-size: 11px;
  }
  .kpi b { font-size: 13px; }
  .clock {
    font-size: 12px;
    letter-spacing: 0;
    padding: 0;
    border-left: 0;
  }
  .nav-link {
    padding: 3px 8px;
    font-size: 11px;
    flex-shrink: 0;
  }
  .nav-link .full { display: none; }
  .nav-link .short { display: inline; }
  .nav-switch {
    padding: 3px 8px;
    font-size: 11px;
    gap: 6px;
    flex-shrink: 0;
  }
  .nav-switch .full { display: none; }
  .nav-switch .short { display: inline; }
  .wrap {
    padding: 12px 12px 28px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .grid { gap: 10px; }
  .card {
    border-radius: 14px;
    padding: 12px 12px 10px;
  }
}
@media (max-width: 360px) {
  .kpi-l { display: none; }
  .kpi {
    min-width: 28px;
    justify-content: center;
    padding: 2px 6px;
  }
  .clock { font-size: 11px; }
}
