:root {
  --bg-dark: #0f172a;
  --bg-mid: #111827;
  --bg-soft: #1e293b;
  --surface: rgba(15, 23, 42, 0.96);
  --surface-alt: #0b1220;
  --line: rgba(148, 163, 184, 0.2);
  --input-text: #000000;
  --input-bg: #ffffff;
  --text: #e2e8f0;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-strong: #0284c7;
  --success: #22c55e;
  --success-strong: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 44px rgba(2, 6, 23, 0.5);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: radial-gradient(circle at top, #1e293b, #0f172a);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    display: block;
    padding: 0;
}

.logo-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.3);
    margin-bottom: 12px;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
  letter-spacing: -0.03em;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    width: 90%;
    padding: 22px;
    box-shadow: var(--shadow);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card {
  width: min(420px, 92vw);
  max-width: 420px;
  margin: 0 auto;
  padding: 26px 24px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 18px 20px 14px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(10px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.85rem;
  font-weight: 700;
}


.success {
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.6);
    color: #dcfce7;
}
.danger {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.6);
    color: #fef2f2;
}

.logout-btn,
.primary-btn,
.secondary-btn,
.success-btn,
.danger-btn {
  padding: 10px 16px;
  font-weight: 700;
  color: #fff;
}

.primary-btn,
.secondary-btn {
  background: var(--primary);
}

.primary-btn:hover,
.secondary-btn:hover {
  background: var(--primary-strong);
}

.success-btn {
  background: var(--success);
  color: #052e16;
}

.success-btn:hover {
  background: var(--success-strong);
}

.danger-btn,
.logout-btn {
  background: var(--danger);
}

.danger-btn:hover,
.logout-btn:hover {
  background: #dc2626;
}

.brand-header {
    display: block;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text);
}

.logo-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
  border-radius: 16px;
  box-shadow: 0 10px 22px rgba(14, 165, 233, 0.3);
}

.logo-icon {
  width: 36px;
  height: 36px;
  fill: #ffffff;
}

.brand-name {
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.05em;
}

.brand-name span {
  color: var(--primary);
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(440px, 90vw);
  padding: 28px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

label {
  font-weight: 700;
  color: var(--text);
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--input-text);
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

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

.admin-management-card {
  width: min(1100px, 94vw);
  padding: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-header h2 {
  margin: 0 0 8px;
}

.table-wrapper {
  overflow-x: auto;
}

.table-loading-shell {
  position: relative;
}

.table-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(2px);
  border-radius: 16px;
  z-index: 3;
}

.table-loading-overlay.hidden {
  display: none;
}

.table-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(148, 163, 184, 0.5);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.table-loading-label {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  text-align: left;
  vertical-align: top;
}

.admin-table thead th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.04);
}

.table-actions-col {
  width: 260px;
}

.admin-table {
  min-width: 760px;
}

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

.small-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
  min-width: auto;
}

.modal-target {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-weight: 600;
}

.modal-form-group {
  margin-top: 0;
}

.empty-table-cell {
  text-align: center;
  color: var(--muted);
  padding: 24px 16px;
}

.gateway-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gateway-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.gateway-link {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.gateway-link:hover {
  color: var(--primary);
}

.gateway-remove-btn {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.gateway-remove-btn:hover {
  background: rgba(239, 68, 68, 0.28);
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  padding: 28px 24px 22px;
  box-shadow: 0 25px 60px rgba(2, 6, 23, 0.7);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.modal-card.is-loading {
  pointer-events: none;
}

.modal-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(2px);
  border-radius: 20px;
  z-index: 2;
}

.modal-loading-overlay.hidden {
  display: none;
}

.modal-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(148, 163, 184, 0.5);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.modal-loading-label {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: var(--primary);
  font-size: 2rem;
  font-weight: 800;
}

.modal-icon-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.modal-card h2 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.modal-card p {
  margin: 0 0 20px;
  color: var(--text-soft);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #fecaca;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: left;
}

.modal-error.hidden {
  display: none;
}

.modal-btn {
  min-width: 140px;
}

.error-text {
  margin-top: 12px;
  color: var(--danger);
  font-weight: 600;
}

.status-text {
  margin-top: 12px;
  color: var(--text-soft);
}

.hidden {
  display: none !important;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  color: var(--text-soft);
}

.plan-list {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.plan-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.plan-option:hover {
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.08);
}

.plan-label {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  font-weight: 700;
  color: var(--text);
}

.plan-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.plan-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--bg-mid);
  color: #fff;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}

.btn-success {
  background: var(--success);
  color: #052e16;
}

.btn-warning {
  background: var(--warning);
  color: #78350f;
}

.approved {
  background-color: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 1);
  color: #ffffff;
}

.pending {
  background-color: rgba(251, 191, 36, 0.2);
  border: 1px solid rgba(251, 191, 36, 1);
  color: #ffffff;
}

.revoked {
  background-color: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 1);
  color: #ffffff;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}
