:root {
  --bg: #f3f7ff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(148, 163, 184, 0.2);
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #14b8a6;
  --text: #0f172a;
  --muted: #5b6477;
  --danger: #ef4444;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 18%),
    radial-gradient(circle at right, rgba(20, 184, 166, 0.14), transparent 20%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.page-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  background: rgba(15, 23, 42, 0.87);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.16);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.brand-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}

nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

nav a, .button-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

nav a:hover, .button-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-logout {
  background: rgba(239, 68, 68, 0.12);
}

.container {
  max-width: 1180px;
  margin: 32px auto;
  padding: 0 18px 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-panel {
  max-width: 500px;
  margin: 72px auto;
}

.auth-header {
  margin-bottom: 16px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.75rem;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  border-radius: 999px;
  padding: 6px 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.auth-form,
.ticket-form,
.filter-form,
.js-action-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-weight: 600;
  color: var(--text);
}

input, textarea, select, button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

button {
  cursor: pointer;
  font-weight: 700;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

button:hover {
  filter: brightness(1.04);
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
}

.secondary-btn {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: white;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.error-box {
  margin-top: 12px;
  padding: 18px 20px;
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.18);
  color: #991b1b;
  font-size: 1.02rem;
  line-height: 1.6;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-form select,
.filter-form input {
  flex: 1;
  min-width: 180px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  color: #0f766e;
  font-weight: 700;
  font-size: 0.78rem;
}

.badge-primary {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 20px 0 28px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(239, 246, 255, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-card strong {
  font-size: 1.6rem;
  color: var(--text);
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.ticket-panel {
  max-width: 820px;
  margin: 0 auto;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.meta-grid > div {
  padding: 12px 14px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.8);
}

.actions .js-action-form {
  display: inline-flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.actions .js-action-form input,
.actions .js-action-form select {
  min-width: 180px;
}

.log-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-list li {
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  text-align: left;
}

th {
  background: linear-gradient(180deg, #eef4ff, #e9f3ff);
  color: #24314d;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: none;
}

pre {
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  padding: 12px 14px;
  overflow-x: auto;
  color: var(--text);
}

.code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.code-row button {
  flex: 0 0 auto;
  width: auto;
  min-width: 140px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.health-shell {
  max-width: 980px;
  margin: 0 auto;
}

.health-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(37, 99, 235, 0.8));
  color: white;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.health-title {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(110, 231, 183, 0.35);
  color: #d1fae5;
  font-weight: 700;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.8);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.health-card {
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: var(--shadow);
}

.health-card-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.health-card-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
}

.health-card-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.health-detail {
  margin-top: 24px;
  padding: 24px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: var(--shadow);
}

.health-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.metric-item {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.metric-item strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.toast.warning {
  background: linear-gradient(135deg, #b45309, #f59e0b);
}

.toast.info {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px;
  }

  nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    flex-direction: column;
  }

  .actions .js-action-form {
    width: 100%;
    flex-wrap: wrap;
  }
}
