:root {
  --brand-primary: #0d4f8b;
  --brand-primary-dark: #093a68;
  --brand-accent: #10b981;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --bg-soft: #f4f6f9;
  --text-dark: #1f2937;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-soft);
  color: var(--text-dark);
  padding-top: var(--topbar-height);
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  background: linear-gradient(90deg, var(--brand-primary-dark), var(--brand-primary));
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  z-index: 1050;
}
.topbar .navbar-brand { color: #fff; }
.topbar .dropdown-toggle::after { color: #fff; }

/* ---------- Layout ---------- */
.app-wrapper { min-height: calc(100vh - var(--topbar-height)); margin-top: var(--topbar-height); }

.sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
}
.sidebar-inner { padding: 1rem 0.75rem; }

.sidebar-nav .nav-section {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9ca3af;
  font-weight: 600;
  margin: 1.1rem 0.75rem 0.35rem;
}
.sidebar-nav .nav-link {
  color: #374151;
  font-size: .92rem;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: #eef4fb; color: var(--brand-primary); }
.sidebar-nav .nav-link.active {
  background: var(--brand-primary);
  color: #fff;
}

.content-area { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1039;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 18px rgba(0,0,0,.15);
  }
  .sidebar.show { transform: translateX(0); }
  .content-area { margin-left: 0; width: 100%; }
  .sidebar-backdrop.show { display: block; }
}

/* ---------- Cards / widgets ---------- */
.card { border: none; border-radius: 14px; box-shadow: 0 2px 10px rgba(15,23,42,.06); }
.card-header { background: transparent; border-bottom: 1px solid #eef0f3; font-weight: 600; border-radius: 14px 14px 0 0 !important; }

.stat-card { border-radius: 14px; color: #fff; padding: 1.25rem 1.4rem; position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: 14px; top: 14px; font-size: 2.4rem; opacity: .25; }
.stat-card h3 { font-weight: 700; margin-bottom: 0; }
.stat-card .label { font-size: .8rem; opacity: .9; text-transform: uppercase; letter-spacing: .05em; }

.stat-card.blue   { background: linear-gradient(135deg, #1c6dd0, #0d4f8b); }
.stat-card.green  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-card.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }

.avatar-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }

.table thead th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.badge { font-weight: 500; padding: .42em .7em; }

/* ---------- Login ---------- */
.login-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary) 60%, #0891b2);
  padding: 1.25rem;
  padding-top: max(1.25rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(0px);
  pointer-events: none;
  background: rgba(255,255,255,.07);
}
.login-orb-1 { width: 420px; height: 420px; top: -160px; left: -140px; }
.login-orb-2 { width: 320px; height: 320px; bottom: -140px; right: -100px; background: rgba(8,145,178,.25); }

.login-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  max-width: 940px;
  width: 100%;
  position: relative;
  z-index: 1;
  box-shadow: 0 20px 60px rgba(6,20,40,.35);
}

.login-side {
  background: linear-gradient(160deg, var(--brand-primary), var(--brand-primary-dark) 75%);
  color: #fff;
  min-height: 100%;
  display: flex;
  align-items: center;
}
.login-side-inner { padding: 3rem 2.75rem; }

.login-brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
}

.login-side-tagline { font-size: .95rem; line-height: 1.55; max-width: 32ch; }

.login-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  margin-bottom: .7rem;
  opacity: .95;
}
.login-feature-list li i { color: var(--brand-accent); font-size: 1rem; flex-shrink: 0; }

.login-form-side {
  padding: 2.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
}

.login-brand-mobile {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--brand-primary);
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}
.login-brand-mobile i {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eef4fb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.login-input-group .input-group-text {
  background: #f8fafc;
  border-right: none;
  color: #64748b;
}
.login-input-group .form-control {
  border-left: none;
  box-shadow: none;
}
.login-input-group .form-control:focus,
.login-input-group:focus-within .input-group-text {
  border-color: var(--brand-primary);
}
.login-input-group .form-control::placeholder { color: #b0b8c4; font-size: .92rem; }

.login-toggle-pw {
  border: 1px solid #ced4da;
  border-left: none;
  background: #fff;
  color: #64748b;
}
.login-toggle-pw:hover { color: var(--brand-primary); }

.login-submit-btn {
  border-radius: 10px;
  padding-top: .75rem;
  padding-bottom: .75rem;
  box-shadow: 0 8px 20px rgba(13,79,139,.25);
}

@media (max-width: 991.98px) {
  .login-card { max-width: 460px; border-radius: 18px; }
  .login-form-side { padding: 2.25rem 1.75rem; }
}

@media (max-width: 420px) {
  .login-form-side { padding: 1.85rem 1.35rem; }
  .login-wrapper { padding: .85rem; }
}

.directory-card { transition: transform .15s ease, box-shadow .15s ease; }
.directory-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(15,23,42,.1); }

.app-footer { margin-left: var(--sidebar-width); }
@media (max-width: 991.98px) { .app-footer { margin-left: 0; } }

.btn-icon { background: transparent; border: none; }

.integration-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #047857;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: .78rem;
  font-weight: 600;
}

/* ---------- Face recognition webcam UI ---------- */
#webcam-container {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  border: 4px solid var(--brand-primary);
}
#webcam-container video,
#webcam-container canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  transform: translate(-50%, -50%) scaleX(-1);
}
#webcam-container canvas { pointer-events: none; }

