:root {
  --bg: #0b0d12;
  --surface: rgba(20, 24, 34, 0.72);
  --surface-strong: rgba(26, 31, 44, 0.92);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f3f5f8;
  --muted: #98a2b3;
  --redbox: #e11d48;
  --redbox-hover: #be123c;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #3b82f6;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.radial-glow {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 460px;
  background: radial-gradient(ellipse at 50% 0%, rgba(225, 29, 72, 0.2), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.875rem; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; }
.center { text-align: center; }

/* Orchestrated Page Entrance */
@keyframes revealUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal-item {
  opacity: 0;
  animation: revealUp 360ms var(--ease-out) forwards;
  animation-delay: calc(var(--stagger, 0) * 50ms);
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--redbox);
  box-shadow: 0 0 12px var(--redbox);
}

/* Layout */
.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.env-pill {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(225, 29, 72, 0.14);
  border: 1px solid rgba(225, 29, 72, 0.35);
  color: #fda4af;
}

/* Sliding Tabs */
.tabs-bar {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 6px;
  overflow-x: auto;
}

.tab-indicator {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  border-radius: 10px;
  background: var(--redbox);
  transition: transform 260ms var(--ease-out), width 260ms var(--ease-out);
  z-index: 0;
}

.tab-btn {
  position: relative;
  z-index: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 200ms ease;
}

.tab-btn.active { color: #fff; }
.tab-btn:hover:not(.active) { color: var(--text); }

.content-area { position: relative; }

@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideFromLeft {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

.tab-panel.slide-right { animation: slideFromRight 240ms var(--ease-out); }
.tab-panel.slide-left { animation: slideFromLeft 240ms var(--ease-out); }

/* Cards & Grids */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.metric-card strong { font-size: 1.5rem; font-weight: 700; }

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}

.panel-card { padding: 20px; }
.panel-card h2 { margin: 0 0 14px 0; font-size: 1.05rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-header h2 { margin: 0; }

.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-md { display: flex; flex-direction: column; gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* Form Elements */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  background: rgba(9, 11, 16, 0.7);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 180ms ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--redbox); }
textarea { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; resize: vertical; }

.checkbox-row, .inline-upload { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 0.84rem; }

/* Buttons */
.btn {
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: transform 120ms ease, background 180ms ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--redbox); color: #fff; }
.btn-primary:hover { background: var(--redbox-hover); }
.btn-secondary { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.22); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-full { width: 100%; }

/* Tables & Code */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.code-box {
  background: #07090d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.79rem;
  overflow: auto;
  max-height: 480px;
  margin: 0;
  color: #e2e8f0;
}

.secret-box {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 10px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
}
.badge-ok { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.badge-warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.badge-err { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }

/* Stacked Toasts */
.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.toast {
  position: relative;
  overflow: hidden;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: toastIn 220ms var(--ease-out);
}

.toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left;
  animation: toastProgress var(--dur, 4000ms) linear forwards;
}

.toast:hover .toast-bar { animation-play-state: paused; }
@keyframes toastProgress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast-success .toast-bar { background: var(--ok); }
.toast-error .toast-bar { background: var(--err); }
.toast-info .toast-bar { background: var(--info); }

@media (prefers-reduced-motion: reduce) {
  .reveal-item, .tab-panel, .tab-indicator, .toast {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
