:root {
  --navy: #16256e;
  --navy-700: #22398f;
  --navy-900: #0e1a4f;
  --accent: #2f9fe0;
  --bg: #eef2fb;
  --card: #ffffff;
  --ink: #101a3e;
  --muted: #5b6685;
  --border: #e1e7f5;
  --ok: #1a7f37;
  --warn: #b54708;
  --danger: #c0392b;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 25, 70, .06), 0 2px 6px rgba(16, 25, 70, .06);
  --shadow-md: 0 10px 30px rgba(16, 25, 70, .12);
  --brand: var(--navy);
  --brand-dark: var(--navy-900);
}

* { box-sizing: border-box; }
img { max-width: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.015em; margin: 0 0 6px; color: var(--ink); }
h2 { font-size: 19px; letter-spacing: -.01em; margin: 0 0 12px; color: var(--ink); }
.subtitle { color: var(--muted); margin-top: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 32px 22px 72px; }
.container.narrow { max-width: 440px; }
.container.mid { max-width: 760px; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-900) 100%);
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 2px 14px rgba(10, 20, 60, .18);
}
.site-header .inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; color: #fff; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 40px; width: 50px; object-fit: contain; display: block; background: #fff; padding: 3px 5px; border-radius: 9px; }
.brand span { color: #cfe0f5; font-weight: 700; }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 4px; }
.nav a {
  font-size: 14px; color: rgba(255, 255, 255, .82); font-weight: 600;
  padding: 7px 12px; border-radius: 9px; transition: background .15s, color .15s;
}
.nav a:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, .12); }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .18); }
.nav-user { font-size: 13px; color: rgba(255, 255, 255, .7); padding: 0 6px; }

/* ---------- Cards & sections ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.page-head { margin-bottom: 22px; }
main > section { margin-bottom: 30px; }
main > section > h2 { font-size: 20px; margin: 0 0 16px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 5px; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=file], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 159, 224, .18); outline: none;
}
textarea { resize: vertical; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.errorlist { color: var(--danger); font-size: 13px; margin: 4px 0; padding-left: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px;
  background: var(--navy); color: #fff; border: 0; font: inherit;
  font-weight: 700; cursor: pointer; text-align: center;
  box-shadow: 0 2px 8px rgba(22, 37, 110, .28);
  transition: transform .12s ease, background .15s, box-shadow .15s;
}
.btn:hover { background: var(--navy-900); text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(22, 37, 110, .32); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1.5px var(--border); }
.btn.secondary:hover { background: #f4f7fe; box-shadow: inset 0 0 0 1.5px var(--navy-700); }
.btn.danger { background: var(--danger); box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: 13px; font-weight: 600; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

.linkedin-btn {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--navy); color: #fff; padding: 12px 20px;
  border-radius: 10px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(22, 37, 110, .28);
  transition: transform .12s ease, background .15s;
}
.linkedin-btn:hover { background: var(--navy-900); text-decoration: none; transform: translateY(-1px); }
.linkedin-btn svg { width: 18px; height: 18px; fill: currentColor; }
.linkedin-btn.alt { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
.linkedin-btn.alt:hover { background: #eef4fc; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 10px; font-size: 14px;
  border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow-sm);
}
.messages li.success { border-color: #abefc6; background: #e9f8ef; color: #12692c; }
.messages li.error { border-color: #f3c0bb; background: #fdeceb; color: #a23125; }
.messages li.warning { border-color: #f5d9b8; background: #fdf3e6; color: #94500a; }
.messages li.info { border-color: #c3d3f5; background: #eef3fd; color: var(--navy); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f7f9fe; }
tbody tr:hover { background: #f7f9fe; }
.table-wrap { overflow-x: auto; border-radius: 10px; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e9eefb; color: var(--navy-700); }
.pill.ok { background: #e6f6ec; color: var(--ok); }
.pill.rev { background: #fdecea; color: var(--danger); }
.pill.pend { background: #fdf1e3; color: var(--warn); }

/* ---------- Admin stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  color: inherit; transition: transform .15s, box-shadow .15s;
}
a.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration: none; border-color: var(--accent); }
.stat .n { font-size: 28px; font-weight: 800; color: var(--navy); letter-spacing: -.02em; }
.stat .l { font-size: 13px; color: var(--muted); }

/* ---------- Student home hero ---------- */
.home-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-900) 70%);
  color: #fff; border: 0;
  box-shadow: var(--shadow-md);
  padding: 34px;
}
.home-hero h1 { color: #fff; font-size: 30px; }
.home-hero .subtitle { color: rgba(255, 255, 255, .86); max-width: 70ch; }
.home-hero .muted { color: rgba(255, 255, 255, .7); }
.home-hero strong { color: #fff; }
.home-logo { height: 110px; width: auto; display: inline-block; background: #fff; padding: 8px 12px; border-radius: 14px; margin-bottom: 16px; }
.home-hero .btn { background: #fff; color: var(--navy); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.home-hero .btn:hover { background: #eef4fc; }
.home-hero .btn.secondary { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55); }
.home-hero .btn.secondary:hover { background: rgba(255, 255, 255, .2); }

.auth-logo { display: block; height: 120px; width: auto; margin: 0 auto 20px; }
.container.auth-page {
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  padding-top: 18px;
  padding-bottom: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-page .card { width: 100%; margin: 0; padding: 24px 26px; }
.auth-page .auth-logo { height: 96px; margin-bottom: 14px; }
.auth-page h1 { font-size: 25px; }
.auth-page .subtitle { margin-bottom: 12px; }
.auth-page label { margin-top: 10px; }
.auth-page .btn-row { margin-top: 14px; }

/* ---------- Course cards ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.course-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.course-card .name { font-weight: 800; font-size: 16px; color: var(--ink); }
.course-card .meta { font-size: 12px; color: var(--muted); margin-top: 5px; }
.course-card p { font-size: 14px; margin: 10px 0 0; color: #3a4467; }
.course-details { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.course-details summary {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--navy-700); font-size: 13px; font-weight: 700;
  cursor: pointer; list-style: none; user-select: none;
}
.course-details summary::-webkit-details-marker { display: none; }
.course-details summary::after { content: "+"; font-size: 17px; line-height: 1; }
.course-details[open] summary::after { content: "−"; }
.course-details .details-less { display: none; }
.course-details[open] .details-more { display: none; }
.course-details[open] .details-less { display: inline; }
.course-details-body { padding-top: 6px; }

/* ---------- Badge grid ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.badge-card {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 18px; text-align: center;
  color: inherit; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.badge-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration: none; }
.badge-card img { width: 132px; height: 132px; object-fit: contain; }
.badge-card .name { font-weight: 700; margin: 12px 0 2px; color: var(--ink); }
.badge-card .meta { font-size: 12px; color: var(--muted); }
.badge-card-cta { display: inline-block; margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--navy-700); }

.empty { text-align: center; padding: 40px 26px; }
.empty p { margin: 6px 0; }
.empty .btn { margin-top: 14px; }

/* ---------- Badge detail ---------- */
.badge-hero { display: flex; gap: 32px; flex-wrap: wrap; align-items: center; }
.badge-hero .credential-badge-image {
  width: 320px;
  height: 320px;
  max-width: 100%;
  object-fit: contain;
}
.kv { margin: 16px 0; }
.kv div { display: flex; gap: 10px; padding: 5px 0; font-size: 14px; }
.kv .k { color: var(--muted); min-width: 120px; }

.badge-hero.center { flex-direction: column; text-align: center; }
.badge-hero.center > div { width: 100%; }
.badge-hero.center .lead { margin-left: auto; margin-right: auto; }
.badge-hero.center .kv { display: inline-block; text-align: left; }
.badge-hero.center .btn-row { justify-content: center; }
.center-card { text-align: center; }
.center-card p { margin-left: auto; margin-right: auto; max-width: 60ch; }
.credential-certificate {
  display: block; width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
}

/* ---------- Compact public credential ---------- */
.container.credential-page { max-width: 1280px; }
.credential-summary-card { padding: 28px; }
.credential-summary {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 30px;
  align-items: start;
}
.credential-primary {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.credential-artwork {
  display: flex;
  align-items: center;
  justify-content: center;
}
.credential-artwork .credential-badge-image {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: contain;
}
.credential-details { min-width: 0; }
.credential-details h1 { font-size: 30px; }
.credential-details .lead { margin-top: 20px; }
.credential-learning {
  min-width: 0;
  padding-left: 28px;
  border-left: 1px solid var(--border);
}
.credential-learning p { margin: 6px 0 0; color: #3a4467; }
.credential-skills { display: flex; flex-wrap: wrap; gap: 7px; }
.certificate-section > h2 { text-align: center; margin-bottom: 20px; }
.certificate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.certificate-item { min-width: 0; }
.certificate-item h3 {
  min-height: 44px;
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}
.certificate-item .credential-certificate {
  aspect-ratio: 1.414 / 1;
  object-fit: contain;
  background: #f8f9fc;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}
.certificate-item .btn-row { justify-content: center; margin-top: 12px; gap: 8px; }
.certificate-item .btn.small { padding: 7px 11px; }

/* ---------- Credential verification ---------- */
.verify-dialog {
  width: min(440px, calc(100% - 32px)); padding: 0; border: 0;
  border-radius: 18px; color: var(--ink); box-shadow: 0 24px 70px rgba(10, 20, 60, .28);
}
.verify-dialog::backdrop { background: rgba(8, 16, 48, .58); backdrop-filter: blur(2px); }
.verify-dialog-close {
  position: absolute; top: 10px; right: 13px; border: 0; background: transparent;
  color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer;
}
.verify-state { padding: 42px 34px 34px; text-align: center; }
.verify-state h2 { margin-top: 18px; font-size: 23px; }
.verify-state p { margin: 8px auto 20px; max-width: 34ch; }
.verify-state .btn { min-width: 130px; }
.verify-spinner {
  display: inline-block; width: 64px; height: 64px; border-radius: 50%;
  border: 6px solid #dce6f8; border-top-color: var(--accent);
  animation: verify-spin .8s linear infinite;
}
.verify-result-icon {
  display: inline-flex; width: 70px; height: 70px; border-radius: 50%;
  align-items: center; justify-content: center; color: #fff;
  font-size: 42px; font-weight: 800; line-height: 1;
}
.verify-result-icon.success { background: var(--ok); }
.verify-result-icon.failure { background: var(--danger); }
[data-verify-credential] { font-weight: 700; color: var(--navy-700); }
@keyframes verify-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .verify-spinner { animation-duration: 1.8s; } }

/* ---------- Misc ---------- */
.checkbox-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.checkbox-list label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 5px 0; }
.checkbox-list input { width: auto; }
.inline-form { display: inline; }
.muted { color: var(--muted); }
.lead { font-size: 16px; color: #3a4467; margin: 6px 0 16px; max-width: 52ch; }
.right { text-align: right; }
.mt { margin-top: 16px; }
code.url { background: #eef2fb; padding: 3px 7px; border-radius: 6px; font-size: 12px; word-break: break-all; color: var(--navy-700); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .site-header .inner { flex-wrap: wrap; }
  .nav { width: 100%; }
  .credential-summary { grid-template-columns: 1fr; }
  .credential-primary { grid-template-columns: 220px minmax(0, 1fr); }
  .credential-learning {
    padding: 24px 0 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .certificate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .container { padding: 22px 16px 56px; }
  .card { padding: 20px; border-radius: 12px; }
  h1 { font-size: 22px; }
  .home-hero { padding: 24px; }
  .home-hero h1 { font-size: 24px; }
  .home-logo { height: 92px; }
  .auth-logo { height: 100px; }
  .container.auth-page { min-height: calc(100dvh - 60px); padding-top: 14px; padding-bottom: 14px; }
  .auth-page .card { padding: 20px; }
  .auth-page .auth-logo { height: 82px; margin-bottom: 12px; }
  .brand { font-size: 16px; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .nav-user { display: none; }
  .badge-hero { gap: 20px; }
  .badge-hero .credential-badge-image { width: 240px; height: 240px; }
  .credential-summary-card { padding: 22px; }
  .credential-summary { gap: 22px; }
  .credential-primary { grid-template-columns: 1fr; gap: 20px; }
  .credential-artwork { min-height: 0; }
  .credential-artwork .credential-badge-image { width: 240px; height: 240px; }
  .credential-details h1 { font-size: 24px; }
  .certificate-grid { grid-template-columns: 1fr; }
  .certificate-item h3 { min-height: 0; }
  .kv .k { min-width: 100px; }
  .btn, .linkedin-btn { width: 100%; }
  .btn.small, .btn-row .btn.small { width: auto; }
}
