/* ==========================================================================
   KeyForge Enterprise Dashboard Design System
   Inspired by Linear, Supabase, and Stripe Dark UI
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Surface colors */
  --bg-app: #090d16;
  --bg-sidebar: #0e131f;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.6);
  --bg-input: rgba(15, 23, 42, 0.9);
  --bg-modal: #0f172a;
  --bg-glass: rgba(15, 23, 42, 0.85);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-focus: #6366f1;

  /* Typography Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Brand & Status Accents */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-cyan: #38bdf8;

  --status-active-bg: rgba(16, 185, 129, 0.12);
  --status-active-text: #34d399;
  --status-active-border: rgba(16, 185, 129, 0.3);

  --status-warning-bg: rgba(245, 158, 11, 0.12);
  --status-warning-text: #fbbf24;
  --status-warning-border: rgba(245, 158, 11, 0.3);

  --status-danger-bg: rgba(244, 63, 94, 0.12);
  --status-danger-text: #fb7185;
  --status-danger-border: rgba(244, 63, 94, 0.3);

  --status-expired-bg: rgba(100, 116, 139, 0.12);
  --status-expired-text: #94a3b8;
  --status-expired-border: rgba(100, 116, 139, 0.3);

  /* Geometry & Fonts */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--border-card);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background Subtle Gradient Glow */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(56, 189, 248, 0.03) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 10;
  position: relative;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon-wrapper {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #38bdf8);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.brand-icon-wrapper svg {
  width: 20px;
  height: 20px;
  color: #ffffff;
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.5px;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  transition: var(--transition);
}

.nav-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-item:hover svg {
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
  color: #ffffff;
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}

.nav-item.active svg {
  color: var(--accent-cyan);
}

/* User & System Status Panel */
.user-panel {
  padding: 16px 18px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #1e293b, #334155);
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

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

.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-panel {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-panel svg {
  width: 14px;
  height: 14px;
}

.btn-icon-panel:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-card);
}

.btn-icon-panel.danger:hover {
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}

/* System Heartbeat Pill */
.system-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 4px 8px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-pill);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Main Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  height: 68px;
  padding: 0 36px;
  background-color: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.page-title-group {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-main);
}

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

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

/* Content Area */
.content-container {
  padding: 32px 36px;
  flex: 1;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-section.active {
  display: block;
}

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

/* Metrics Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.metric-card:hover {
  border-color: var(--border-card);
  transform: translateY(-2px);
}

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

.metric-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.metric-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.metric-icon svg {
  width: 15px;
  height: 15px;
}

.metric-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Data Tables */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  backdrop-filter: blur(12px);
  margin-bottom: 24px;
}

.table-toolbar {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.01);
  gap: 16px;
}

.table-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.table-search-box svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
}

.search-input {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 14px 8px 36px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 260px;
  font-family: var(--font-sans);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  width: 300px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  padding: 12px 20px;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

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

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.badge-active {
  background-color: var(--status-active-bg);
  color: var(--status-active-text);
  border: 1px solid var(--status-active-border);
}
.badge-active .badge-dot { background-color: var(--status-active-text); }

.badge-revoked {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
}
.badge-revoked .badge-dot { background-color: var(--status-danger-text); }

.badge-suspended {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}
.badge-suspended .badge-dot { background-color: var(--status-warning-text); }

.badge-expired {
  background-color: var(--status-expired-bg);
  color: var(--status-expired-text);
  border: 1px solid var(--status-expired-border);
}
.badge-expired .badge-dot { background-color: var(--status-expired-text); }

/* Monospace Code Pill */
.code-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--accent-cyan);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.code-copyable {
  cursor: pointer;
  transition: var(--transition);
}

.code-copyable:hover {
  background-color: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  user-select: none;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-card);
}

.btn-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}

.btn-danger:hover {
  background-color: rgba(244, 63, 94, 0.2);
  border-color: #f43f5e;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(5, 8, 15, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-box {
  background-color: var(--bg-modal);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close-btn svg {
  width: 18px;
  height: 18px;
}

.modal-close-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font-sans);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Playground View */
.playground-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 28px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}

.terminal-result {
  background-color: #030712;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent-cyan);
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 18px;
  line-height: 1.6;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-modal);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px);
  opacity: 0;
  transition: var(--transition);
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast svg {
  width: 18px;
  height: 18px;
}

.toast.success svg { color: #10b981; }
.toast.error svg { color: #f43f5e; }
.toast.info svg { color: #38bdf8; }

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  color: var(--text-dim);
  opacity: 0.6;
}
