:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #ffffff;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar-text: #e5e7eb;
  --soft-blue: #eff6ff;
  --soft-purple: #f5f3ff;
  --soft-green: #ecfdf5;
  --soft-orange: #fff7ed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: #f8fafc;
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--bg), var(--panel));
  color: var(--sidebar-text);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(37,99,235,0.22);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
}

.brand h2, .brand p { margin: 0; }
.brand p { font-size: 13px; color: #cbd5e1; }

.user-panel {
  background: rgba(255,255,255,0.06);
  padding: 14px;
  border-radius: 14px;
}

.user-panel p {
  margin: 6px 0;
  font-size: 14px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-btn, button {
  border: none;
  outline: none;
  cursor: pointer;
  transition: 0.2s ease;
}

.menu-btn {
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 14px;
}

.menu-btn:hover,
.menu-btn.active {
  background: rgba(37,99,235,0.35);
}

.sidebar-footer { margin-top: auto; }

.main-content {
  padding: 24px;
  background: #f8fafc;
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
}

.auth-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: 100%;
  max-width: 1180px;
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 24px;
}

.auth-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff;
  border-radius: 24px;
  padding: 34px;
  box-shadow: 0 12px 40px rgba(15,23,42,0.18);
}

.auth-hero h1 {
  font-size: 38px;
  line-height: 1.15;
  margin: 18px 0 14px;
}

.auth-hero .muted {
  color: #dbeafe;
  max-width: 540px;
}

.pill {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  font-size: 13px;
  font-weight: 600;
}

.hero-points {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.hero-point {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}

.hero-point strong,
.hero-point span {
  display: block;
}

.hero-point span {
  margin-top: 4px;
  color: #dbeafe;
  font-size: 14px;
}

.public-auth-card { padding: 28px; }

.auth-tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 6px;
  border-radius: 14px;
  margin-bottom: 24px;
}

.auth-tab {
  background: transparent;
  color: #334155;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
}

.auth-tab.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(15,23,42,0.08);
}

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

.grid {
  display: grid;
  gap: 20px;
}

.grid.two { grid-template-columns: 1fr 1fr; }

.header-row,
.section-head,
.insight-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.header-row { margin-bottom: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field label {
  font-weight: 600;
  font-size: 14px;
}

.field-error {
  min-height: 14px;
  font-size: 12px;
  color: var(--danger);
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
  background: #fff;
}

input:focus, select:focus {
  outline: 2px solid rgba(37,99,235,0.18);
  border-color: #93c5fd;
}

button {
  background: var(--primary);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 600;
}

button:hover { background: var(--primary-dark); }

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

button.secondary:hover { background: #cbd5e1; }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.actions.wrap { flex-wrap: wrap; }

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.admin-toolbar {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.toolbar-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbar-item label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

.export-actions { margin-bottom: 18px; }

.form-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 12px;
  background: #10b981;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  min-width: 180px;
}

.form-link:hover { background: #059669; }

.disabled-link {
  pointer-events: none;
  opacity: 0.55;
  background: #cbd5e1;
  color: #475569;
}

.list-wrap {
  display: grid;
  gap: 12px;
}

.training-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #f8fafc;
}

.training-item h3,
.training-item p {
  margin: 0 0 8px;
}

.badge,
.status-chip,
.insight-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.published { background: #dcfce7; color: #166534; }
.badge.draft { background: #fef3c7; color: #92400e; }
.badge.completed { background: #dbeafe; color: #1d4ed8; }

.status-chip {
  background: #eef2ff;
  color: #3730a3;
}

.note-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.note-box p { margin: 6px 0; }

.muted { color: var(--text-light); }
.hidden { display: none !important; }

.sub-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #f8fafc;
  margin-top: 16px;
}

.sub-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.compact-summary {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  min-height: 60px;
}

.mini-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-light);
}

.stats-grid,
.admin-overview-grid {
  display: grid;
  gap: 18px;
}

.stats-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 20px;
}

.admin-overview-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 22px;
}

.stat-card,
.insight-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
}

.insight-primary {
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border-color: #dbeafe;
}

.insight-kicker,
.stat-label {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 600;
}

.trend {
  font-size: 12px;
  font-weight: 700;
}

.trend.positive { color: #15803d; }
.trend.neutral { color: #475569; }

.admin-sections { margin-bottom: 20px; }
.admin-monitor-card { margin-top: 20px; }

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

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

table th,
table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.empty-state {
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--text-light);
}

.summary-grid-2 {
  display: grid;
  gap: 18px;
}

.summary-mini-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #f8fafc;
}

.summary-mini-card h3 {
  margin: 0 0 10px;
}

.certificate-note {
  color: #166534;
  font-weight: 600;
}

.faq-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  background: #fafafa;
}

.faq-item h3 { margin: 0 0 8px; }

.app-footer {
  margin-top: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-light);
  font-size: 14px;
}

.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

.toast-container {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 9999;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.18);
  color: #fff;
  animation: slideIn .2s ease;
}

.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }
.toast.warn { background: #d97706; }

@keyframes slideIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#nexusMount { min-height: 320px; }

.nx-app {
  background: #f8fafc;
  color: #0f172a;
}

.nx-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.nx-topbar h1 { margin: 0; }

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

.nx-role-badge {
  background: #e0e7ff;
  color: #312e81;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.nx-grid {
  display: grid;
  gap: 20px;
}

.nx-grid-two {
  grid-template-columns: 1.2fr 1fr;
}

.nx-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px;
}

.nx-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.nx-field input,
.nx-field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

.nx-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nx-link-list {
  display: grid;
  gap: 12px;
}

.nx-link-item {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
}

.nx-link-item h3,
.nx-link-item p {
  margin: 0 0 8px;
}

.nx-link-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.nx-open-link {
  text-decoration: none;
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  background: #eef2ff;
  color: #312e81;
  font-weight: 600;
}

.nx-btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.nx-muted { color: #64748b; }

@media (max-width: 1180px) {
  .auth-panel,
  .stats-grid,
  .admin-overview-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .grid.two,
  .form-grid,
  .auth-panel,
  .nx-grid-two,
  .stats-grid,
  .admin-overview-grid,
  .toolbar,
  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  .app-footer {
    flex-direction: column;
  }
}