/* CILT Student Registration Admin Panel — design system
   Arial only. No Google Fonts, no glassmorphism, no gradients, no shimmer. */

:root {
  --cilt-purple: #361163;
  --cilt-purple-dark: #1e0938;
  --cilt-gold:   #C0A582;
  --cilt-steel:  #505050;
  --cilt-pale:   #ebebeb;
  --cilt-green:  #b7d432;
  --cilt-blue:   #00a8e5;
  --cilt-red:    #b72049;
  --border: #d8d8d8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--cilt-steel);
  background: #f5f5f5;
}

a { color: var(--cilt-purple); }

h1, h2, h3, h4 { font-family: Arial, sans-serif; color: var(--cilt-purple); margin: 0 0 12px; }

/* ---------- Header / nav ---------- */
.admin-header {
  background: var(--cilt-purple);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  box-shadow: 0 2px 8px rgba(54,17,99,.2);
  position: sticky;
  top: 0;
  z-index: 40;
}
.admin-header .brand {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
  letter-spacing: .02em;
}
.admin-header .brand span { color: var(--cilt-gold); }
.admin-nav { display: flex; gap: 4px; align-items: center; }
.admin-nav a {
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .03em;
  opacity: .85;
}
.admin-nav a:hover, .admin-nav a.active { opacity: 1; background: rgba(255,255,255,.12); }
.admin-nav button.logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  padding: 7px 14px;
  border-radius: 4px;
  text-transform: uppercase;
  font-size: 12px;
  cursor: pointer;
}
.admin-nav button.logout-btn:hover { background: rgba(255,255,255,.12); }

/* ---------- Nav dropdown (e.g. "Импорт" -> Вручную / Автосинхронизация BHA) ---------- */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  font-family: Arial, sans-serif;
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .03em;
  opacity: .85;
  cursor: pointer;
}
.nav-dropdown-trigger::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: -3px;
}
.nav-dropdown-trigger:hover,
.nav-dropdown-trigger.active,
.nav-dropdown.open .nav-dropdown-trigger,
.nav-dropdown:focus-within .nav-dropdown-trigger { opacity: 1; background: rgba(255,255,255,.12); }

.nav-dropdown-menu {
  display: none;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  margin-top: 4px;
  padding: 6px;
  background: var(--cilt-purple-dark);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 50;
}
.nav-dropdown-menu a {
  padding: 9px 12px;
  white-space: nowrap;
  border-radius: 4px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu { display: flex; }

.admin-main { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 11px 22px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(54,17,99,.1);
  text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--cilt-purple); color: #fff; }
.btn-primary:hover { background: var(--cilt-purple-dark); }
.btn-secondary { background: #fff; color: var(--cilt-purple); border: 2px solid var(--cilt-purple); box-shadow: none; }
.btn-secondary:hover { background: var(--cilt-pale); }
.btn-gold { background: var(--cilt-gold); color: var(--cilt-purple); }
.btn-gold:hover { opacity: .88; }
.btn-danger { background: #fff; color: var(--cilt-red); border: 2px solid var(--cilt-red); box-shadow: none; }
.btn-danger:hover { background: #fbeaef; }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
  border-radius: 4px;
  box-shadow: none;
  color: var(--cilt-purple);
}
.btn-icon:hover { background: var(--cilt-pale); }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-paid { background: rgba(183,212,50,.2); color: #5a7c00; }
.badge-unpaid { background: rgba(183,32,73,.12); color: var(--cilt-red); }
.badge-live { background: rgba(0,168,229,.14); color: #0077a3; }
.badge-withdrawn { background: rgba(183,32,73,.12); color: var(--cilt-red); }
.badge-deferred { background: rgba(255,210,4,.18); color: #8a7000; }
.badge-active { background: rgba(0,168,229,.14); color: #0077a3; }
.badge-completed { background: rgba(183,212,50,.2); color: #5a7c00; }
.badge-issued { background: rgba(183,212,50,.2); color: #5a7c00; }
.badge-revoked { background: rgba(183,32,73,.12); color: var(--cilt-red); }
.badge-qual { background: var(--cilt-pale); color: var(--cilt-steel); }
/* Program/cohort tag (GIZ Project 2025 etc.) — deliberately violet, distinct
   from every other badge color above, since it marks an orthogonal fact
   ("which special cohort") rather than a status like paid/live/issued. */
.badge-program { background: rgba(74,58,167,.14); color: var(--cilt-purple); }

/* Membership grade ladder — one consistent purple ramp, light to dark as the
   grade rises (Affiliate lowest → Chartered Fellow highest), so grade level
   reads at a glance instead of all four sharing the same neutral grey chip.
   Text flips light↔dark to stay readable as the background darkens; the top
   tier pairs gold text on purple — the same combination the brandbook uses
   for the inverse logo — so Chartered Fellow reads as the premium tier. */
.badge-grade-affiliate { background: #F2E9FA; color: var(--cilt-purple); border: 1px solid rgba(54,17,99,.15); }
.badge-grade-milt      { background: #C9A8E0; color: var(--cilt-purple-dark); }
.badge-grade-cmilt     { background: #7A45B3; color: #fff; }
.badge-grade-fcilt     { background: var(--cilt-purple); color: var(--cilt-gold); }
.badge-grade-declined  { background: rgba(183,32,73,.12); color: var(--cilt-red); }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

/* ---------- KPI cards ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card {
  background: #fff;
  border-top: 4px solid var(--cilt-purple);
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  padding: 18px 20px;
}
.kpi-card .kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #888; margin-bottom: 6px; }
.kpi-card .kpi-value { font-size: 32px; font-weight: bold; color: var(--cilt-purple); }

/* ---------- BHA sync diff ---------- */
.diff-entry { padding: 12px 0; border-bottom: 1px solid var(--cilt-pale-grey, #ebebeb); font-size: 14px; }
.diff-entry:last-child { border-bottom: none; }
.diff-entry ul { margin: 6px 0 0; padding-left: 20px; color: #505050; }
.diff-entry li { margin-bottom: 2px; }

/* ---------- Forms ---------- */
.form-section { margin-bottom: 24px; }
.form-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 2px solid var(--cilt-pale);
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 14px; }
.form-row.single { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: repeat(3, 1fr); }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: bold; color: var(--cilt-steel); text-transform: uppercase; letter-spacing: .02em; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: Arial, sans-serif;
  color: var(--cilt-steel);
  border: 2px solid var(--border);
  border-radius: 4px;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--cilt-purple);
  box-shadow: 0 0 0 3px rgba(54,17,99,.1);
}
.form-input[readonly], .form-input:disabled { background: var(--cilt-pale); color: #888; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: #888; }
.form-error { font-size: 12px; color: var(--cilt-red); margin-top: 4px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--cilt-pale); justify-content: space-between; }
.form-actions .form-actions-left { display: flex; gap: 12px; }

/* ---------- Filter panel ---------- */
.filter-panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-panel .form-group { min-width: 160px; flex: 1; }
.filter-panel .filter-actions { display: flex; gap: 8px; }

/* ---------- Tables ---------- */
.table-wrap { background: #fff; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.07); overflow: hidden; }
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table thead { background: var(--cilt-purple); }
table.data-table th {
  color: #fff;
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: bold;
  white-space: nowrap;
}
table.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--cilt-pale); font-size: 14px; }
table.data-table tbody tr:hover { background: #faf9fb; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table a.row-link { color: var(--cilt-purple); font-weight: bold; text-decoration: none; }
table.data-table a.row-link:hover { text-decoration: underline; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px; }
.pagination button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--cilt-steel);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button.active { background: var(--cilt-purple); color: #fff; border-color: var(--cilt-purple); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: #999; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state p { margin: 0 0 16px; }

/* ---------- Modal ---------- */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(54,17,99,.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
#modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(54,17,99,.24);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--cilt-pale); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #888; line-height: 1; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--cilt-pale); display: flex; justify-content: flex-end; gap: 12px; }

/* ---------- Auth guard overlay ---------- */
#auth-guard {
  position: fixed; inset: 0;
  background: #fff;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
#auth-guard.hidden { display: none; }
#auth-guard .guard-text { color: #aaa; font-size: 14px; margin-top: 12px; text-align: center; }
#auth-guard .guard-logo { font-size: 20px; font-weight: bold; color: var(--cilt-purple); text-align: center; }
#auth-guard .guard-logo span { color: var(--cilt-gold); }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--cilt-purple);
  color: #fff;
  padding: 12px 20px;
  border-radius: 4px;
  box-shadow: 0 8px 28px rgba(54,17,99,.24);
  font-size: 14px;
  z-index: 300;
  display: none;
}
#toast.show { display: block; }
#toast.error { background: var(--cilt-red); }

/* ---------- Login page ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--cilt-pale); }
.login-card { background: #fff; border-radius: 8px; box-shadow: 0 10px 32px rgba(54,17,99,.14); padding: 40px; width: 100%; max-width: 380px; }
.login-card .logo { text-align: center; font-size: 22px; font-weight: bold; color: var(--cilt-purple); margin-bottom: 4px; }
.login-card .logo span { color: var(--cilt-gold); }
.login-card .subtitle { text-align: center; color: #999; font-size: 13px; margin-bottom: 28px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.login-card .login-link { text-align: center; margin-top: 16px; font-size: 13px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: #999; }
.checkbox { width: 16px; height: 16px; accent-color: var(--cilt-purple); }

/* ---------- Student card page ---------- */
.card-header {
  background: var(--cilt-purple);
  color: #fff;
  border-radius: 8px;
  padding: 24px 28px;
  margin-bottom: 20px;
}
.card-header .provider-code { font-size: 12px; letter-spacing: .1em; color: var(--cilt-gold); text-transform: uppercase; }
.card-header .batch-no { font-size: 14px; opacity: .85; margin-left: 8px; }
.card-header .cert-name-en { font-size: 26px; font-weight: bold; margin: 8px 0 2px; }
.card-header .cert-name-ru { font-size: 16px; color: var(--cilt-gold); }
.card-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--cilt-pale); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: #888; }
.info-row .info-value { font-weight: bold; text-align: right; }
.qr-box { text-align: center; }
.qr-box canvas { border: 1px solid var(--border); border-radius: 4px; }

@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr; }
  .form-row, .form-row.triple { grid-template-columns: 1fr; }
}

/* ---------- Print (student card) ---------- */
@media print {
  .admin-header, .filter-panel, .no-print, #auth-guard, #toast, #modal-overlay { display: none !important; }
  body { background: #fff; }
  .admin-main { max-width: none; padding: 0; }
  .card, .card-header { box-shadow: none; }
}
