:root {
  --bg: #05070f;
  --panel: #0b1220;
  --panel-2: #10182b;
  --panel-3: #0f1524;
  --line: #1e2a3f;
  --glow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --accent: #20e3b2;
  --accent-2: #f97316;
  --accent-3: #5dd1ff;
  --danger: #ff5c8a;
  --success: #44ffb2;
  --warning: #ffc857;
  --text: #eaf2ff;
  --text-dim: #9fb2d4;
  --font-body: "Manrope", "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Orbitron", "Manrope", sans-serif;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --blur: 16px;
}

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

body {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, rgba(32, 227, 178, 0.08), transparent 30%),
              radial-gradient(circle at 80% 0%, rgba(93, 209, 255, 0.1), transparent 35%),
              radial-gradient(circle at 40% 80%, rgba(249, 115, 22, 0.08), transparent 40%),
              var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  padding: 0;
  overflow-x: hidden;
}

.app-shell {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.ambient {
  position: fixed;
  filter: blur(80px);
  opacity: 0.35;
  mix-blend-mode: screen;
  z-index: -1;
}
.ambient-a { inset: -120px auto auto -140px; width: 360px; height: 360px; background: #20e3b2; }
.ambient-b { inset: auto -160px -120px auto; width: 420px; height: 420px; background: #5dd1ff; }

.layout {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  width: 100%;
}

.sidebar {
  width: 100%;
  background: linear-gradient(135deg, rgba(16, 24, 43, 0.92), rgba(11, 18, 32, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow);
  backdrop-filter: blur(var(--blur));
  position: sticky;
  top: 20px;
  z-index: 10;
}

.nav-shell {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #20e3b2, #5dd1ff);
  color: #051018;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  letter-spacing: 0.4px;
  box-shadow: 0 15px 40px rgba(32, 227, 178, 0.25);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-title {
  font-family: var(--font-display);
  letter-spacing: 0.4px;
}

.brand-copy small {
  color: var(--text-dim);
  font-size: 12px;
}

.nav-menu {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  border-color: rgba(32, 227, 178, 0.4);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(135deg, #20e3b2, #5dd1ff);
  color: #051018;
  box-shadow: 0 10px 40px rgba(93, 209, 255, 0.25);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #f97316, #ffb86c);
  color: #0a0f1c;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.user-name {
  font-weight: 700;
}

.user-role {
  color: var(--text-dim);
  font-size: 12px;
}

.main-content {
  width: 100%;
}

.view {
  background: linear-gradient(145deg, rgba(11, 18, 32, 0.8), rgba(16, 24, 43, 0.74));
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow);
  padding: 20px;
}

.view-login {
  background: linear-gradient(135deg, rgba(11, 18, 32, 0.94), rgba(16, 24, 43, 0.86));
}

.login-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.login-hero {
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
}

.login-hero h1 {
  font-family: var(--font-display);
  margin: 8px 0;
  line-height: 1.3;
}

.lead {
  color: var(--text-dim);
  margin-bottom: 12px;
}

.login-highlights {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.login-highlights li {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.login-card {
  background: var(--panel-2);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.login-card-head {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.form-stack {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

input,
textarea,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 12px;
  font-size: 15px;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  font-family: var(--font-body);
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(32, 227, 178, 0.8);
  box-shadow: 0 0 0 3px rgba(32, 227, 178, 0.12);
}

textarea { resize: vertical; }

.input-with-action {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn.primary {
  background: linear-gradient(135deg, #20e3b2, #5dd1ff);
  color: #051018;
  box-shadow: 0 10px 40px rgba(93, 209, 255, 0.25);
}

.btn.secondary {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.22), rgba(93, 209, 255, 0.2));
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.btn-danger {
  background: rgba(255, 92, 138, 0.15);
  border: 1px solid rgba(255, 92, 138, 0.5);
  color: #ffc5d9;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn.text {
  background: transparent;
  color: var(--text-dim);
  padding-left: 0;
}

.btn.sm { padding: 9px 12px; font-size: 14px; }
.btn.btn-sm { padding: 9px 12px; font-size: 14px; }
.btn.btn-sm { padding: 9px 12px; font-size: 14px; }
.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.ghost-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(32, 227, 178, 0.12);
  border: 1px solid rgba(32, 227, 178, 0.4);
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-size: 12px;
}

.chip-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px; }
.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
  font-size: 12px;
}
.chip.success { border-color: rgba(68, 255, 178, 0.5); color: #6effc6; }
.chip.info { border-color: rgba(93, 209, 255, 0.5); color: #a7e6ff; }
.chip.warning { border-color: rgba(249, 115, 22, 0.5); color: #fcbc7c; }

.page-hero {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.page-hero h1 {
  font-family: var(--font-display);
  margin: 6px 0;
}

.hero-actions { display: flex; gap: 10px; align-items: center; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.35s ease; }

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

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(32, 227, 178, 0.14);
  display: grid;
  place-items: center;
  color: #9bf4de;
  font-size: 18px;
}

.stat-label { color: var(--text-dim); font-size: 13px; }
.stat-value { font-family: var(--font-display); font-size: 26px; }

.panel {
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.35);
}

.panel-grid.two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-header.between { flex-wrap: wrap; }

.panel-header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 14px;
}
.panel-hint .pill { margin-right: 2px; }

.panel-body { display: block; }

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.data-table thead th {
  text-align: left;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.data-table tbody td {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 14px;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.text-center { text-align: center; }

/* Key list containment */
.key-table-wrapper {
  overflow: auto;
  max-height: clamp(320px, 55vh, 620px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.key-table-wrapper .data-table {
  min-width: 760px;
  table-layout: fixed;
}

.key-table-wrapper .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(16, 24, 43, 0.94);
  backdrop-filter: blur(8px);
}

.key-table-wrapper .data-table th,
.key-table-wrapper .data-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-table-wrapper .data-table th:nth-child(1),
.key-table-wrapper .data-table td:nth-child(1) { width: 22%; }
.key-table-wrapper .data-table th:nth-child(2),
.key-table-wrapper .data-table td:nth-child(2) { width: 18%; }
.key-table-wrapper .data-table th:nth-child(3),
.key-table-wrapper .data-table td:nth-child(3) { width: 12%; }
.key-table-wrapper .data-table th:nth-child(4),
.key-table-wrapper .data-table td:nth-child(4) { width: 12%; }
.key-table-wrapper .data-table th:nth-child(5),
.key-table-wrapper .data-table td:nth-child(5) { width: 12%; }
.key-table-wrapper .data-table th:nth-child(6),
.key-table-wrapper .data-table td:nth-child(6) { width: 8%; }
.key-table-wrapper .data-table th:nth-child(7),
.key-table-wrapper .data-table td:nth-child(7) { width: 16%; }

.key-table-wrapper .data-table td:last-child {
  width: 360px;
}

.key-table-wrapper [data-copy] {
  cursor: pointer;
  display: inline-block;
}
.key-table-wrapper [data-copy]:hover {
  color: var(--text);
  text-decoration: underline;
}

.key-code {
  font-family: "Space Grotesk", "SFMono-Regular", "Menlo", monospace;
  letter-spacing: 0.08em;
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.key-table-wrapper .action-group {
  gap: 6px;
  justify-content: flex-end;
}

.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.input.select { padding-right: 34px; }

.form-grid.two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.form-control { display: grid; gap: 6px; }
.form-control.full { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.info-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 6px;
}

.activity-list { display: grid; gap: 10px; }
.activity-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.activity-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(93, 209, 255, 0.12);
  color: #b7e9ff;
}
.activity-action { font-weight: 700; }
.activity-desc { color: var(--text-dim); }
.activity-time { color: var(--text-dim); font-size: 12px; }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.alert-error {
  border-color: rgba(255, 92, 138, 0.5);
  color: #ffc5d9;
  background: rgba(255, 92, 138, 0.08);
}

.toast-container,
#toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--panel-3);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
  display: flex;
  gap: 8px;
  align-items: center;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); color: #ffc5d9; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 18px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}

.modal-lg { max-width: 760px; }
.modal-md { max-width: 540px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-body { color: var(--text); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.api-pill {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: "Space Grotesk", monospace;
}

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 4000;
  align-items: center;
  justify-content: center;
}

.loading-overlay.show { display: flex; }

.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.key-display {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.settings-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.settings-value { font-weight: 700; font-size: 16px; }

.login-foot { margin-top: 10px; }

.action-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
}
.badge-success { border-color: rgba(68, 255, 178, 0.5); color: #6effc6; }
.badge-danger { border-color: rgba(255, 92, 138, 0.5); color: #ffc5d9; }
.badge-warning { border-color: rgba(255, 200, 87, 0.6); color: #ffe5a3; }
.badge-info { border-color: rgba(93, 209, 255, 0.5); color: #b7e9ff; }
.badge-active { border-color: rgba(68, 255, 178, 0.5); color: #6effc6; }
.badge-expiring { border-color: rgba(249, 115, 22, 0.5); color: #fcbc7c; }
.badge-expired { border-color: rgba(255, 92, 138, 0.5); color: #ffc5d9; }

.detail-section { display: grid; gap: 10px; }
.detail-row { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: center; }
.detail-row label { color: var(--text-dim); font-weight: 600; }
.detail-value { word-break: break-word; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

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

/* Responsive */
@media (max-width: 1024px) {
  .login-grid { grid-template-columns: 1fr; }
  .nav-shell { align-items: flex-start; }
  .nav-menu { justify-content: flex-start; }
  .brand-cluster { width: 100%; }
}

@media (max-width: 720px) {
  .layout { gap: 12px; }
  .sidebar { position: static; }
  .nav-shell { flex-direction: column; align-items: flex-start; }
  .nav-actions { width: 100%; justify-content: flex-start; }
  .page-hero { flex-direction: column; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; justify-content: center; }
  .btn.ghost.sm, .btn.sm { width: auto; }
}

@media (max-width: 520px) {
  .app-shell { padding: 18px 14px 32px; }
  .panel-grid.two { grid-template-columns: 1fr; }
  .nav-menu { flex-direction: column; width: 100%; }
  .nav-item { width: 100%; justify-content: flex-start; }
  .table-wrapper { border: none; }
}
