:root {
  --bg: #0a0b0f;
  --bg-card: #12131a;
  --bg-card-hover: #181922;
  --border: #1e2030;
  --border-accent: #2a2d45;
  --text: #e4e4f0;
  --text-dim: #8888a4;
  --text-muted: #555570;
  --accent: #00e5a0;
  --accent-dim: #00e5a020;
  --accent-glow: #00e5a040;
  --orange: #ff8a3d;
  --blue: #5b8cff;
  --red: #ff5b6a;
  --purple: #a07bff;
  --yellow: #ffd56a;
  --radius: 10px;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Ambient Background (matches landing page) ─── */
body::before {
  content: '';
  position: fixed;
  top: -40%; left: -20%;
  width: 80vw; height: 80vw;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: drift 20s ease-in-out infinite alternate;
}
@keyframes drift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(10vw, 15vh); }
}

/* ─── Animations ─── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Layout ─── */
.dash-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--bg-card) 0%, #0e0f16 100%);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0 24px;
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}
.sidebar-logo span { color: var(--text-dim); font-weight: 400; }

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  color: var(--text);
  background: var(--accent-dim);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
  box-shadow: inset 4px 0 12px var(--accent-dim);
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: block;
  width: 100%;
  padding: 10px;
  text-align: center;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.logout-btn:hover {
  color: var(--red);
  border-color: var(--red);
  background: #ff5b6a08;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px 40px;
  max-width: 1000px;
  position: relative;
  z-index: 1;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.page-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

/* ─── Cards ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.25s;
}
.stat-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-value.accent { color: var(--accent); }
.stat-value.orange { color: var(--orange); }
.stat-value.blue { color: var(--blue); }

/* ─── Tier Badge ─── */
.tier-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}
.tier-badge.free { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }
.tier-badge.basic { background: #5b8cff15; color: var(--blue); border: 1px solid var(--blue); }
.tier-badge.pro { background: #a07bff15; color: var(--purple); border: 1px solid var(--purple); }
.tier-badge.enterprise { background: #ff8a3d15; color: var(--orange); border: 1px solid var(--orange); }

/* ─── Tables ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.data-table th {
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  transition: all 0.15s;
}
.data-table tr:hover td {
  background: var(--bg-card);
  border-left: 2px solid var(--accent);
}
.data-table tr:hover td:first-child {
  border-left: 2px solid var(--accent);
}

.key-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}

.status-active { color: var(--accent); }
.status-revoked { color: var(--text-muted); }

/* ─── Buttons ─── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--accent);
  color: #0a0b0f;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--border-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover {
  background: #ff5b6a10;
  transform: translateY(-1px);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ─── Progress Bar ─── */
.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00c98a);
  border-radius: 6px;
  transition: width 0.6s ease;
  position: relative;
  background-size: 200% 100%;
  animation: shimmer 3s ease infinite;
}
.progress-fill.warn {
  background: linear-gradient(90deg, var(--orange), #e07530);
  background-size: 200% 100%;
}
.progress-fill.danger {
  background: linear-gradient(90deg, var(--red), #e04050);
  background-size: 200% 100%;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  backdrop-filter: blur(4px);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s ease;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  margin-top: -8px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }

/* ─── Toast ─── */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 14px 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.9rem;
  z-index: 200;
  display: none;
  animation: slideIn 0.3s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.toast.error {
  border-color: var(--red);
  color: var(--red);
}
.toast.hiding {
  animation: slideOut 0.3s ease forwards;
}

/* ─── Billing Cards ─── */
.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.billing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.25s;
  position: relative;
}
.billing-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.billing-card.current {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-dim);
}
.billing-card.featured {
  border-color: var(--purple);
  background: linear-gradient(180deg, #1a1025 0%, var(--bg-card) 100%);
}
.billing-card.featured::before {
  content: 'MOST POPULAR';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--purple);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 100px;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}

.billing-card .tier-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.billing-card .tier-price {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 12px;
}
.billing-card .tier-price span {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 400;
}
.billing-card .tier-features {
  list-style: none;
  margin-bottom: 20px;
}
.billing-card .tier-features li {
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 4px 0;
}
.billing-card .tier-features li::before {
  content: '\2713 ';
  color: var(--accent);
  margin-right: 6px;
}

.billing-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.trust-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ─── Form inputs ─── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ─── Copy box ─── */
.copy-box {
  display: flex;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  align-items: center;
  margin: 8px 0;
  transition: border-color 0.2s;
}
.copy-box:hover {
  border-color: var(--border-accent);
}
.copy-box code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  word-break: break-all;
}
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font-mono);
  white-space: nowrap;
  transition: all 0.2s;
}
.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
}

/* ─── Locked state ─── */
.locked-overlay {
  text-align: center;
  padding: 60px 20px;
}
.locked-overlay .lock-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}
.locked-overlay h3 {
  margin-bottom: 8px;
}
.locked-overlay p {
  color: var(--text-dim);
  margin-bottom: 24px;
}

/* ─── Section show/hide ─── */
.section { display: none; }
.section.active {
  display: block;
  animation: fadeInUp 0.35s ease-out;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-logo { margin-bottom: 0; margin-right: 24px; }
  .sidebar-nav { display: flex; gap: 4px; flex: 1; }
  .nav-item {
    padding: 8px 14px;
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    font-size: 0.8rem;
  }
  .nav-item.active {
    border-bottom-color: var(--accent);
    border-left: none;
    box-shadow: none;
  }
  .nav-item .nav-icon { display: none; }
  .sidebar-footer { border-top: none; padding: 0 0 0 12px; }
  .main-content { margin-left: 0; margin-top: 56px; padding: 20px 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .billing-grid { grid-template-columns: 1fr; }
}
