:root {
  --bg: #12140f;
  --panel: rgba(28, 32, 24, 0.88);
  --line: rgba(232, 220, 190, 0.14);
  --text: #f3efe4;
  --muted: #a39e90;
  --accent: #d97706;
  --accent-2: #fbbf24;
  --ok: #86efac;
  --bad: #fb7185;
  --font: 'DM Sans', system-ui, sans-serif;
  --display: 'Syne', 'DM Sans', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  background: var(--bg);
}

body {
  position: relative;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(243, 239, 228, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 239, 228, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 20%, black 20%, transparent 75%);
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  width: 60vw;
  height: 60vw;
  left: -10vw;
  top: -20vw;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.22), transparent 60%);
  filter: blur(10px);
  pointer-events: none;
  animation: drift 12s ease-in-out infinite alternate;
}

.bg-glow-2 {
  left: auto;
  right: -15vw;
  top: 40vh;
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.12), transparent 65%);
  animation-duration: 16s;
  animation-direction: alternate-reverse;
}

@keyframes drift {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(8vw, 4vh);
  }
}

.auth-view {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: 22px;
  padding: 28px 26px 22px;
  animation: rise 0.55s ease both;
}

.auth-card .eyebrow {
  margin: 0 0 10px;
  color: var(--accent-2);
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  line-height: 1.15;
}

.auth-card .lead {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.auth-form .field {
  margin-bottom: 14px;
}

.auth-switch {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-switch a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.admin-mini {
  display: block;
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
}

.admin-mini:hover {
  color: var(--text);
}

.btn.full {
  width: 100%;
  margin-top: 6px;
}

.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  animation: rise 0.5s ease both;
}

.brand {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 1.25rem;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  transition: 0.2s ease;
}

.admin-link:hover {
  color: var(--text);
  border-color: rgba(251, 191, 36, 0.45);
}

.stage {
  position: relative;
  z-index: 2;
  width: min(920px, calc(100% - 40px));
  margin: 18px auto 60px;
}

.hero {
  margin-bottom: 28px;
  animation: rise 0.7s ease both;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-2);
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 600;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.lead {
  margin: 16px 0 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 22px;
  animation: rise 0.8s ease 0.08s both;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.field > span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.field input:focus {
  border-color: rgba(251, 191, 36, 0.7);
}

.field small {
  color: var(--muted);
  font-size: 0.8rem;
}

.levels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.custom-level {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.custom-level.hidden {
  display: none;
}

.custom-level label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.custom-level input {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.levels button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  font: inherit;
  transition: 0.2s ease;
}

.levels button:hover {
  border-color: rgba(251, 191, 36, 0.45);
}

.levels button.active {
  background: linear-gradient(135deg, var(--accent), #b45309);
  border-color: transparent;
  color: #1a1205;
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 14px 22px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    opacity 0.2s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #1a1205;
  min-width: 140px;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.metrics {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  animation: rise 0.85s ease 0.14s both;
}

.metrics article {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.metrics strong {
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
}

.metrics .fail {
  color: var(--bad);
}

.metrics .status {
  font-size: 1.25rem;
}

.log-panel {
  margin-top: 18px;
  animation: rise 0.88s ease 0.16s both;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.log-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.log-clear {
  min-width: auto;
  padding: 6px 12px;
  font-size: 0.82rem;
}

.stress-log {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
}

.stress-log:empty::before {
  content: '暂无日志，开始测压后将在此追加显示';
  color: var(--muted);
  opacity: 0.8;
}

.stress-log .log-line {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
}

.stress-log .log-time {
  color: var(--accent, #d4a017);
  margin-right: 8px;
}

.kami-panel {
  margin-top: 18px;
  animation: rise 0.9s ease 0.18s both;
}

.kami-head h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.15rem;
}

.kami-head p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.kami-unbound .btn {
  width: 100%;
}

.kami-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.kami-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.kami-meta strong {
  font-size: 0.98rem;
  word-break: break-all;
}

.footnote {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(20, 18, 12, 0.95);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--text);
  font-size: 0.92rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: rise 0.25s ease both;
}

/* 全局确认弹窗：必须脱离文档流，铺满视口 */
#confirmModal.modal,
.modal.cc-global-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  z-index: 2147483000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  box-sizing: border-box !important;
  background: transparent !important;
}

#confirmModal.modal.hidden,
.modal.cc-global-modal.hidden {
  display: none !important;
}

#confirmModal .modal-backdrop,
.cc-global-modal .modal-backdrop {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(6, 7, 5, 0.78) !important;
  backdrop-filter: blur(6px);
}

#confirmModal .modal-card,
.cc-global-modal .modal-card {
  position: relative !important;
  z-index: 1;
  width: min(92vw, 440px);
  max-height: min(80vh, 560px);
  overflow: auto;
  padding: 24px 22px 18px;
  border-radius: 16px;
  background: rgba(28, 32, 24, 0.98);
  border: 1px solid rgba(232, 220, 190, 0.18);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  animation: modal-in 0.22s ease both;
}

#confirmModal .modal-card h3,
.cc-global-modal .modal-card h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

#confirmModal .modal-msg,
.cc-global-modal .modal-msg {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

#confirmModal .modal-actions,
.cc-global-modal .modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

#confirmModal .modal-actions .btn,
.cc-global-modal .modal-actions .btn {
  min-width: 108px;
}

body.cc-modal-open {
  overflow: hidden !important;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast {
  animation: toast-in 0.25s ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 720px) {
  .levels,
  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .top {
    padding: 18px 16px;
  }
}
