:root {
  --bg: #160d0f;
  --bg-surface: #1e1214;
  --bg-raised: #261619;
  --wine: #9b2040;
  --wine-dim: #7a1630;
  --wine-bright: #c02848;
  --wine-glow: rgba(155, 32, 64, 0.18);
  --text: #ecdcde;
  --text-dim: #907078;
  --text-muted: #5c3840;
  --success: #4ade80;
  --error: #f87171;
  --border: rgba(155, 32, 64, 0.18);
  --radius: 8px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Pulse animations */
@keyframes ambient-breathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@keyframes border-breathe {
  0%, 100% {
    border-color: rgba(155, 32, 64, 0.16);
    box-shadow: none;
  }
  50% {
    border-color: rgba(155, 32, 64, 0.38);
    box-shadow: 0 0 18px rgba(155, 32, 64, 0.07);
  }
}

@keyframes nav-breathe {
  0%, 100% {
    border-bottom-color: rgba(155, 32, 64, 0.15);
    box-shadow: none;
  }
  50% {
    border-bottom-color: rgba(155, 32, 64, 0.38);
    box-shadow: 0 1px 28px rgba(155, 32, 64, 0.1);
  }
}

@keyframes spin { to { transform: rotate(360deg); } }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 60px;
  position: relative;
}

/* Ambient mystical glow — the living energy of the page */
body::before {
  content: '';
  position: fixed;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 55%;
  background: radial-gradient(ellipse at center, rgba(155, 32, 64, 0.09) 0%, transparent 68%);
  pointer-events: none;
  z-index: 0;
  animation: ambient-breathe 8s ease-in-out infinite;
}

body > * { position: relative; z-index: 1; }

a { color: var(--wine-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; color: var(--text); }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.page { padding: 24px 0; }

/* Nav */
nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  animation: nav-breathe 9s ease-in-out infinite;
}
.nav-brand {
  color: var(--wine-bright);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.05em;
}
.nav-links { display: flex; gap: 16px; flex: 1; }
.nav-links a { color: var(--text-dim); font-size: 0.85rem; transition: color 0.15s; }
.nav-links a:hover, .nav-links a.active { color: var(--wine-bright); text-decoration: none; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  animation: border-breathe 7s ease-in-out infinite;
}
.card:nth-child(2) { animation-delay: -2.3s; }
.card:nth-child(3) { animation-delay: -4.6s; }
.card:nth-child(4) { animation-delay: -1.1s; }
.card:nth-child(5) { animation-delay: -3.5s; }
.card:hover {
  border-color: rgba(155, 32, 64, 0.55) !important;
  box-shadow: 0 0 24px rgba(155, 32, 64, 0.12) !important;
  animation: none;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  animation: border-breathe 7s ease-in-out infinite;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--wine-bright); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  font-family: var(--font);
}
.btn-primary { background: var(--wine); color: #f0d0d5; }
.btn-primary:hover { background: var(--wine-bright); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--wine-dim); }
.btn-danger { background: transparent; color: var(--error); border: 1px solid rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.1); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--wine-bright); }
.form-group textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-raised); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid rgba(155,32,64,0.06); vertical-align: middle; }
tr:hover td { background: var(--bg-raised); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-amber { background: rgba(155,32,64,0.15); color: var(--wine-bright); }
.badge-green { background: rgba(74,222,128,0.12); color: var(--success); }
.badge-red { background: rgba(248,113,113,0.12); color: var(--error); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--text-dim); }

/* Status bar */
#status-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
  z-index: 200;
}
#status-bar .status-msg { color: var(--text); flex: 1; }
#status-bar .status-time { color: var(--text-muted); }

/* Section headers */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* Section cards */
.section-card { display: block; text-decoration: none; cursor: pointer; }
.section-card:hover { text-decoration: none; }
.section-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--wine-bright);
  margin-bottom: 8px;
}
.section-card p { color: var(--text-dim); font-size: 0.82rem; margin-top: 4px; }

/* Activity feed */
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(155,32,64,0.06); }
.activity-icon {
  width: 36px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
  flex-shrink: 0;
}
.activity-icon.ok { background: rgba(74,222,128,0.1); color: var(--success); }
.activity-icon.fail { background: rgba(248,113,113,0.1); color: var(--error); }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-surface);
  border: 1px solid rgba(155,32,64,0.35);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(155,32,64,0.1);
}
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 20px; color: var(--wine-bright); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(155,32,64,0.3);
  border-top-color: var(--wine-bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* Slug display */
.slug-url { font-family: monospace; font-size: 0.8rem; color: var(--wine-dim); background: var(--bg-raised); padding: 2px 6px; border-radius: 4px; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty-state p { margin-top: 8px; font-size: 0.9rem; }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle-slider:before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: 0.2s;
}
input:checked + .toggle-slider { background: rgba(155,32,64,0.2); border-color: var(--wine); }
input:checked + .toggle-slider:before { background: var(--wine-bright); transform: translateX(18px); }

/* Responsive */
@media (max-width: 600px) {
  .nav-links { display: none; }
  .card-grid { grid-template-columns: 1fr; }
}
