:root {
  --bg: #0c0d10;
  --bg-soft: #14151a;
  --card: #17181e;
  --card-2: #1d1f26;
  --line: rgba(255, 255, 255, 0.07);
  --text: #f4f5f7;
  --muted: #9aa0aa;
  --faint: #6b707a;
  --accent: #f5a524;
  --accent-soft: rgba(245, 165, 36, 0.14);
  --green: #34c759;
  --red: #ff5f57;
  --blue: #6ea8fe;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% -20%, rgba(245, 165, 36, 0.10), transparent 60%),
    radial-gradient(80% 40% at 100% 0%, rgba(110, 168, 254, 0.06), transparent 60%);
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100dvh; }

/* ── 登录 ─────────────────────────────────────────── */
.login {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 28px calc(32px + env(safe-area-inset-bottom));
}

.login .mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #f7b955, #e08a12);
  color: #191100;
  box-shadow: 0 12px 40px rgba(245, 165, 36, 0.28);
  margin-bottom: 22px;
}

.login h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 28px; font-size: 14px; }

.passcode {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.passcode input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font-size: 22px;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 14px 16px;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.passcode input:focus { border-color: rgba(245, 165, 36, 0.55); }

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--accent); color: #1a1200; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-allow { background: var(--green); color: #07130a; }
.btn-deny { background: rgba(255, 95, 87, 0.12); color: #ff8a84; border: 1px solid rgba(255, 95, 87, 0.25); }

.error { color: #ff8a84; font-size: 13px; min-height: 18px; margin: 0 0 12px; }

.login-hint { margin: 18px 0 0; font-size: 12.5px; color: var(--faint); text-align: center; }
.login-hint code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; }

/* ── 主界面 ───────────────────────────────────────── */
.shell {
  min-height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(14px + env(safe-area-inset-top)) 20px 12px;
  background: rgba(12, 13, 16, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.header.scrolled { border-bottom-color: var(--line); }

.header .row { display: flex; align-items: center; gap: 10px; }
.header h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; font-weight: 700; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  transition: background 0.2s ease;
}

.dot.on { background: var(--green); box-shadow: 0 0 12px rgba(52, 199, 89, 0.6); }
.dot.off { background: var(--red); }

.header .sub {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 13px;
  margin-top: 14px;
}

.segmented button {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button.active { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset; }
.segmented .badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--accent);
  color: #1a1200;
  font-size: 11.5px;
  line-height: 18px;
  vertical-align: 1px;
}

main {
  flex: 1;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── 卡片 ─────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--card), rgba(23, 24, 30, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.card.pending { border-color: rgba(245, 165, 36, 0.28); box-shadow: 0 10px 30px -18px rgba(245, 165, 36, 0.5); }
.card.flash { animation: flash 1.4s ease; }

@keyframes flash {
  0%, 40% { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  100% { border-color: var(--line); box-shadow: none; }
}

.card .top { display: flex; align-items: flex-start; gap: 11px; }

.kind {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--bg-soft);
  color: var(--muted);
}

.kind.approval { background: var(--accent-soft); color: var(--accent); }
.kind.question { background: rgba(110, 168, 254, 0.13); color: var(--blue); }
.kind.done { background: rgba(52, 199, 89, 0.12); color: var(--green); }
.kind.failed { background: rgba(255, 95, 87, 0.12); color: var(--red); }

.card .title { font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; margin: 1px 0 2px; word-break: break-word; }
.card .time { margin-left: auto; color: var(--faint); font-size: 12px; flex: none; padding-top: 4px; font-variant-numeric: tabular-nums; }
.card .body { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }

.card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.status-allowed { color: var(--green); border-color: rgba(52, 199, 89, 0.25); background: rgba(52, 199, 89, 0.08); }
.chip.status-denied { color: #ff8a84; border-color: rgba(255, 95, 87, 0.25); background: rgba(255, 95, 87, 0.08); }
.chip.status-expired { color: var(--faint); }

.actions { display: flex; gap: 9px; margin-top: 13px; }
.actions .btn { font-size: 15px; padding: 11px 14px; }
.actions .btn-allow { flex: 1.4; }
.actions .btn-deny { flex: 1; }

.options { display: flex; flex-direction: column; gap: 8px; margin-top: 13px; }
.options .btn { text-align: left; background: var(--card-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; font-size: 14.5px; padding: 12px 14px; }
.options .btn:active { background: var(--accent-soft); border-color: rgba(245, 165, 36, 0.4); }

.card a.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--blue);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}

/* ── 空状态 / 骨架 ────────────────────────────────── */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}

.empty .ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  margin-bottom: 6px;
}

.empty h2 { font-size: 17px; color: var(--text); margin: 0; font-weight: 600; }
.empty p { margin: 0; font-size: 13.5px; color: var(--faint); }

.skeleton {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ── 底部 / 浮层 ──────────────────────────────────── */
.footer {
  text-align: center;
  color: var(--faint);
  font-size: 11.5px;
  padding: 6px 0 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: #262831;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 90;
  max-width: 84vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.offline-bar {
  background: rgba(255, 95, 87, 0.14);
  color: #ff9d98;
  font-size: 12.5px;
  text-align: center;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 95, 87, 0.2);
}

/* ── 概览分组 ─────────────────────────────────────── */
.group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--faint);
  text-transform: uppercase;
}

.group-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1px 7px;
  letter-spacing: 0;
  text-transform: none;
}

.group-count.accent { color: var(--accent); border-color: rgba(245, 165, 36, 0.3); background: var(--accent-soft); }

/* ── 运行中 ───────────────────────────────────────── */
.run-card {
  position: relative;
  background: linear-gradient(180deg, rgba(52, 199, 89, 0.07), rgba(23, 24, 30, 0.94));
  border: 1px solid rgba(52, 199, 89, 0.22);
  border-radius: var(--radius);
  padding: 13px 15px 12px;
}

.run-top { display: flex; align-items: center; gap: 9px; }
.run-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-elapsed { margin-left: auto; color: var(--green); font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; }

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  position: relative;
}

.pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(52, 199, 89, 0.6);
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  80%, 100% { transform: scale(1.5); opacity: 0; }
}

.run-step { margin-top: 7px; font-size: 13.5px; color: var(--muted); display: flex; gap: 4px; align-items: baseline; }
.run-step-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-ago { color: var(--faint); font-size: 12px; flex: none; }
.run-meta { margin-top: 6px; font-size: 11.5px; color: var(--faint); }

/* ── 刚刚完成 ─────────────────────────────────────── */
.done-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.done-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}

.done-row:last-child { border-bottom: 0; }

.done-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--bg-soft);
  color: var(--muted);
}

.done-icon.done { color: var(--green); background: rgba(52, 199, 89, 0.1); }
.done-icon.failed { color: var(--red); background: rgba(255, 95, 87, 0.1); }
.done-icon svg { width: 13px; height: 13px; }

.done-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-time { margin-left: auto; font-size: 11.5px; color: var(--faint); flex: none; }
