/* ====== Token Gateway Admin — CSS ====== */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242838;
  --border: #2d3245;
  --text: #e4e6f0;
  --text-dim: #8b8fa3;
  --accent: #6c8cff;
  --accent-hover: #8ba3ff;
  --green: #34d399;
  --red: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ====== Login ====== */
.page { display: none; }
.page.active { display: flex; }

#page-login {
  align-items: center; justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 32px; }

.login-card input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color .2s;
}
.login-card input:focus { border-color: var(--accent); }

.login-card button {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.login-card button:hover { background: var(--accent-hover); }

.error-msg { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ====== Header ====== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 40px; }
.logo { font-weight: 700; font-size: 16px; }

nav { display: flex; gap: 4px; }
.nav-item {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--accent); background: var(--surface-2); }

.header-right { display: flex; align-items: center; gap: 16px; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.btn-small {
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn-small:hover {
  background: var(--border);
}

/* ====== Pages ====== */
#page-main { display: none; flex-direction: column; }
#page-main.active { display: flex; }

.page-inner { display: none; padding: 32px; max-width: 1200px; margin: 0 auto; width: 100%; }
.page-inner.active { display: block; }

/* ====== Stats ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.stat-label { color: var(--text-dim); font-size: 13px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; }

/* ====== Card ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.card h3 { margin-bottom: 16px; font-size: 16px; }

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  overflow-x: auto;
}
.code-block pre {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent);
  line-height: 1.6;
}

/* ====== Section Header ====== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header button {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.section-header button:hover { background: var(--accent-hover); }

/* ====== Table ====== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: var(--surface-2); }

td .api-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
td .api-key:hover { color: var(--accent); }

.action-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
}
.action-btn:hover { color: var(--text); border-color: var(--accent); }
.action-btn.danger:hover { color: var(--red); border-color: var(--red); }
.action-btn.success { color: var(--green); border-color: var(--green); }
.action-btn.success:hover { background: var(--green); color: #000; }

/* ====== Usage Filter ====== */
.usage-filter { margin-bottom: 16px; }
.usage-filter select {
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

/* ====== Modal ====== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: 90%;
  max-width: 480px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 16px;
}

.modal-close {
  font-size: 24px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

#modal-body { padding: 24px; }

.modal-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }

.modal-btn {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.modal-btn:hover { background: var(--accent-hover); }
.modal-btn.secondary { background: var(--surface-2); color: var(--text); }
.modal-btn.secondary:hover { background: var(--border); }

.modal-actions { display: flex; gap: 8px; margin-top: 8px; }
.modal-actions .modal-btn { flex: 1; }

/* ====== Utility ====== */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #000;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  z-index: 2000;
}
.copy-toast.show { opacity: 1; }

/* ====== Responsive ====== */
@media (max-width: 768px) {
  header { padding: 0 16px; }
  .header-left { gap: 16px; }
  nav { gap: 0; }
  .nav-item { padding: 8px 10px; font-size: 13px; }
  .page-inner { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
}
