:root {
  color-scheme: dark;
  --bg: #07070c;
  --card: #12121a;
  --soft: #1a1a26;
  --text: #f3f0ff;
  --muted: #9a95b0;
  --accent: #8b6cff;
  --accent2: #ff4d9a;
  --ok: #5ddea0;
  --warn: #ffc857;
  --danger: #ff6b8a;
  --border: rgba(255, 255, 255, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Login gate ---------- */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 10% -10%, rgba(139, 108, 255, 0.22), transparent 55%),
    radial-gradient(700px 400px at 100% 0%, rgba(255, 77, 154, 0.14), transparent 50%),
    rgba(7, 7, 12, 0.96);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px 24px 22px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(18, 18, 26, 0.95);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.login-panel .sub {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.login-panel .field {
  margin-bottom: 12px;
}

.login-panel label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.login-panel input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  font: inherit;
}

.login-btn {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

.login-btn.face {
  background: rgba(139, 108, 255, 0.16);
  border: 1px solid rgba(139, 108, 255, 0.4);
  color: var(--text);
}

.login-btn.face:disabled {
  opacity: 0.45;
}

/* 醒目：登录并录入 / 系统 Face ID 大按钮 */
.login-btn.enroll {
  background: linear-gradient(135deg, #8b6cff, #6a4dff 45%, #ff4d9a);
  border: 0;
  color: #fff;
  font-weight: 750;
  box-shadow: 0 10px 28px rgba(139, 108, 255, 0.35);
}

.login-btn.enroll:disabled {
  opacity: 0.65;
  cursor: wait;
}

.login-error {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 107, 138, 0.12);
  border: 1px solid rgba(255, 107, 138, 0.35);
  color: #ffb3c2;
  font-size: 0.88rem;
}

.login-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.login-hint code {
  font-family: var(--mono);
  color: #d4ceff;
  font-size: 0.85em;
}

/* Face 录入弹层 */
.face-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: end center;
  padding: 0;
  background: rgba(0, 0, 0, 0.72);
}

.face-modal-backdrop[hidden] {
  display: none !important;
}

.face-modal {
  width: min(440px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  padding: 18px 18px 22px;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: #12121a;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
}

.face-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.face-modal-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.face-diag {
  margin: 8px 0 12px;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}

#faceEnrollStatus {
  margin: 0 0 12px;
  font-size: 0.92rem;
}

#faceEnrollStatusText.ok {
  color: var(--ok);
}

#faceEnrollStatusText.need {
  color: var(--warn);
}

#faceEnrollMsg {
  margin-top: 12px;
}

#faceEnrollMsg.err {
  color: #ffb3c2;
}

#faceEnrollMsg.ok {
  color: var(--ok);
}

body.locked .app {
  /* 登录时不遮挡操作：只隐藏主界面交互，登录层独立 */
  visibility: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 0% -10%, rgba(139, 108, 255, 0.2), transparent 55%),
    radial-gradient(800px 400px at 100% 0%, rgba(255, 77, 154, 0.12), transparent 50%),
    var(--bg);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(139, 108, 255, 0.18);
  border: 1px solid rgba(139, 108, 255, 0.35);
  color: #d9d0ff;
  font-size: 0.78rem;
  font-weight: 650;
  margin-bottom: 10px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
  letter-spacing: -0.03em;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.5;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 10px;
}

.stat {
  background: rgba(18, 18, 26, 0.9);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  min-width: 72px;
}

.stat span {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease, transform 0.15s ease;
}

.stat span.bump {
  color: var(--ok);
  transform: scale(1.08);
}

.stat-total span {
  font-size: 1.55rem;
  color: #e8e2ff;
}

.stat label {
  color: var(--muted);
  font-size: 0.75rem;
}

.live-board {
  margin-bottom: 14px;
}

.live-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 6px;
  background: var(--muted);
  vertical-align: middle;
}

.live-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(93, 222, 160, 0.15);
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.live-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.live-card {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 12px 10px;
}

.live-k {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.live-v {
  font-size: 1.65rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.live-s {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  min-height: 2.2em;
  word-break: break-all;
}

.live-line {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  color: #d7d2ef;
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 4.2em;
  overflow: hidden;
}

.mono {
  font-family: var(--mono);
}

@media (max-width: 720px) {
  .live-grid {
    grid-template-columns: 1fr;
  }
  .hero-stats {
    grid-template-columns: repeat(2, minmax(70px, 1fr));
    width: 100%;
  }
}

.card {
  background: rgba(18, 18, 26, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
  backdrop-filter: blur(12px);
}

.path {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
  word-break: break-all;
}

.actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filters {
  margin-top: 12px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  border-color: rgba(139, 108, 255, 0.45);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6a4dff 50%, var(--accent2));
  border: none;
  box-shadow: 0 10px 24px rgba(139, 108, 255, 0.28);
}

.btn.danger {
  background: rgba(255, 107, 138, 0.15);
  border-color: rgba(255, 107, 138, 0.4);
  color: #ffc0cd;
}

.btn.ghost {
  background: transparent;
}

.btn.mini {
  padding: 4px 10px;
  font-size: 0.8rem;
}

input[type="search"],
select {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0c0c14;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  min-width: 160px;
}

input[type="search"] {
  flex: 1;
  min-width: 220px;
}

.log-head,
.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.log {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  background: #0a0a12;
  border-radius: 12px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: #cfc8e8;
  white-space: pre-wrap;
  word-break: break-word;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #161622;
  z-index: 1;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

tr:hover td {
  background: rgba(139, 108, 255, 0.06);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
}

.pill.ok {
  background: rgba(93, 222, 160, 0.15);
  color: var(--ok);
}
.pill.warn {
  background: rgba(255, 200, 87, 0.15);
  color: var(--warn);
}
.pill.err {
  background: rgba(255, 107, 138, 0.15);
  color: var(--danger);
}
.pill.dim {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.path-cell {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 240px;
  word-break: break-all;
}

.footer {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

code {
  font-family: var(--mono);
  color: #d4ceff;
}

@media (max-width: 720px) {
  .hero-stats {
    width: 100%;
  }
  th:nth-child(7),
  td:nth-child(7) {
    display: none;
  }
}
