:root {
  --brand: #4338ca;
  --brand-dark: #312e81;
  --brand-light: #eef2ff;
}
body { background: #f4f6fb; }

.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}
.login-card { width: 380px; border: none; border-radius: 14px; }
.login-icon { font-size: 40px; }

.app-navbar { background: linear-gradient(90deg, var(--brand-dark), var(--brand)); }
.app-shell { min-height: calc(100vh - 56px); }
.app-sidebar {
  width: 230px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  min-height: calc(100vh - 56px);
  padding-top: 10px;
}
.app-sidebar .nav-link {
  color: #374151;
  padding: 10px 18px;
  border-left: 3px solid transparent;
  font-size: 0.94rem;
}
.app-sidebar .nav-link i { margin-right: 8px; width: 18px; display: inline-block; text-align: center; }
.app-sidebar .nav-link.active, .app-sidebar .nav-link:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-left-color: var(--brand);
}
.app-main { background: #f4f6fb; }

.card-header-brand {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}

.stat-card { border-radius: 12px; border: none; color: #fff; }
.stat-card .stat-num { font-size: 2rem; font-weight: 700; }
.bg-purple { background: linear-gradient(135deg, #6366f1, #4338ca); }
.bg-teal { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.bg-orange { background: linear-gradient(135deg, #f59e0b, #b45309); }
.bg-pink { background: linear-gradient(135deg, #ec4899, #9d174d); }

/* ---- Certificate Builder ---- */
.builder-wrap { display: flex; gap: 16px; min-width: 0; }
.builder-canvas-outer {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 78vh;
  overflow: auto;
  border: 1px solid #d1d5db;
  background: #ddd;
  overscroll-behavior: contain;
}
#builderCanvas {
  position: relative;
  background-size: cover;
  background-position: center;
  margin: 0;
}
.field-box {
  position: absolute;
  cursor: move;
  padding: 2px 4px;
  border: 1px dashed rgba(67,56,202,.7);
  background: rgba(255,255,255,.35);
  white-space: nowrap;
  user-select: none;
  line-height: 1.1;
  touch-action: none;
}
.field-box.dragging { opacity: .8; cursor: grabbing; }
.field-box.resizing { opacity: .8; }
.field-box .resize-handle {
  position: absolute; right: -7px; bottom: -7px; width: 12px; height: 12px;
  border: 2px solid #fff; background: #2563eb; cursor: ew-resize; touch-action: none;
}
#builderCanvas.drop-target { outline: 3px dashed #2563eb; outline-offset: -3px; }
.field-box.selected { border: 2px solid #ec4899; background: rgba(236,72,153,.15); }
.field-box .del-handle {
  position: absolute; top: -10px; right: -10px; background: #dc2626; color: #fff;
  border-radius: 50%; width: 18px; height: 18px; font-size: 11px; line-height: 18px;
  text-align: center; cursor: pointer;
}
.builder-sidebar { width: 300px; flex-shrink: 0; }

/* ---- Certificate print/view ---- */
.cert-outer { overflow: auto; }
.cert-pages { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.cert-page { position: relative; background-size: cover; background-position: center; margin: 0 auto; }
.cert-page-2 { margin-top: 0; }
#certCanvas { position: relative; background-size: cover; background-position: center; margin: 0 auto; }
#certCanvasPage2 { position: relative; background-size: cover; background-position: center; margin: 0 auto; }
.cert-field { position: absolute; white-space: nowrap; }

@media (max-width: 768px) {
  .builder-wrap { display: block; }
  .builder-canvas-outer { width: 100%; max-height: 65vh; }
  .builder-sidebar { width: 100%; margin-top: 16px; }
}

@media print {
  body * { visibility: hidden; }
  #certCanvas, #certCanvas * { visibility: visible; }
  #certCanvas { position: absolute; top: 0; left: 0; margin: 0; }
  @page { margin: 0; }
}

@media print {
  .no-print { display: none !important; }
}
