*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-card: #151f32;
  --border: #243044;
  --border-soft: #1c2738;
  --text: #e8eef7;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 260px;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a {
  color: #60a5fa;
  text-decoration: none;
}

a:hover {
  color: #93c5fd;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app-guest {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.12), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(34, 197, 94, 0.08), transparent 30%),
    var(--bg);
}

.sidebar {
  background: linear-gradient(180deg, #0d1526 0%, #0a101c 100%);
  border-right: 1px solid var(--border-soft);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #22c55e);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.98rem;
}

.sidebar-brand .muted {
  font-size: 0.78rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: #bfdbfe;
}

.nav-icon {
  opacity: 0.85;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.main-wrap {
  padding: 1.5rem 2rem 3rem;
  max-width: 1180px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card h2, .card h3 {
  margin: 0 0 0.5rem;
}

.lead {
  color: var(--text-muted);
  margin-top: 0;
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid.two {
    grid-template-columns: 1fr 1fr;
  }

  .grid.three {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid.four {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.25rem;
}

.stat-card {
  background: linear-gradient(180deg, #172033 0%, #121a29 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.stat-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stat-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-meta {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stat-meta.positive { color: #86efac; }
.stat-meta.negative { color: #fca5a5; }

.quota-block {
  margin: 1rem 0;
}

.quota-bar {
  height: 10px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.quota-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.quota-fill.warn { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.chart-wrap {
  margin-top: 1rem;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding-top: 0.5rem;
}

.chart-bar {
  flex: 1;
  min-width: 6px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-radius: 4px 4px 0 0;
  opacity: 0.85;
}

.chart-bar:hover {
  opacity: 1;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 0.5rem;
}

.tab {
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  color: var(--text);
}

.tab.is-active {
  background: var(--accent-soft);
  color: #bfdbfe;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}

.steps li {
  counter-increment: step;
  padding-left: 3rem;
  position: relative;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #93c5fd;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.code-block {
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
  margin: 0.75rem 0;
  position: relative;
}

.code-block code {
  font-family: "Cascadia Code", "Consolas", monospace;
  white-space: pre;
}

.code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.code-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-copy:hover {
  color: var(--text);
  border-color: #475569;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.health-dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
.health-dot.bad { background: var(--danger); }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #3a4a63;
  background: #0a101a;
  color: #f8fafc;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.92rem;
}

button:hover,
.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: white;
}

.btn-secondary {
  background: #243044;
}

.btn-secondary:hover {
  background: #2f3f57;
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  font-weight: 500;
}

.btn-text:hover {
  color: var(--text);
  background: transparent;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(127, 29, 29, 0.35);
  border: 1px solid #991b1b;
  color: #fecaca;
}

.alert-success {
  background: rgba(20, 83, 45, 0.35);
  border: 1px solid #166534;
  color: #bbf7d0;
}

.alert-warning {
  background: rgba(120, 53, 15, 0.35);
  border: 1px solid #b45309;
  color: #fde68a;
}

.status-badge {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pending,
.status-processing {
  background: rgba(245, 158, 11, 0.15);
  color: #fdba74;
}

.status-verified {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.status-rejected,
.status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.status-active {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.status-trial {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.status-suspended {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border-soft);
}

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.meta-list {
  display: grid;
  gap: 0.85rem;
}

.meta-list dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.meta-list dd {
  margin: 0;
}

.login-card {
  width: min(420px, 100%);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-footer {
    margin-top: 0;
    border-top: none;
    margin-left: auto;
  }

  .main-wrap {
    padding: 1rem;
  }
}
