:root {
  color-scheme: light dark;
  --ink: light-dark(#132138, #f0f4fa);
  --muted: light-dark(#4c5f78, #bdc9da);
  --paper: light-dark(#fff, #1b2537);
  --canvas: light-dark(#f2f5f9, #111928);
  --line: light-dark(#dce4ee, #394860);
  --accent: light-dark(#ae2e1c, #ff9a89);
  --primary: #b53220;
  --navy: #132138;
  font: 400 15px/1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.18; letter-spacing: -.035em; }
h2 { font-size: 19px; line-height: 1.3; }
p { color: var(--muted); }
select, button, input { font: inherit; }
button, select { cursor: pointer; }
:is(button, select, input, a):focus-visible { outline: 2px solid #5592ee; outline-offset: 3px; }

#academy-partner-portal { min-height: 100vh; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.portal-wrap { width: min(100%, 1200px); padding-inline: clamp(14px, 4vw, 40px); margin-inline: auto; }
.portal-header { background: var(--navy); color: #fff; }
.portal-header-inner, .portal-brand, .portal-header-controls, .portal-footer, .portal-course-top, .portal-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.portal-header-inner { min-height: 72px; padding-block: 12px; justify-content: space-between; }
.portal-brand { gap: 10px 14px; font-weight: 650; }
.tenant-brand { display: flex; align-items: center; border-inline-end: 1px solid #4a5971; padding-inline-end: 14px; }
.tenant-name { max-inline-size: 225px; }
.tenant-logo, .academy-logo { display: block; inline-size: auto; max-inline-size: 135px; block-size: 38px; object-fit: contain; background: white; padding: 4px 8px; border-radius: 6px; }
.portal-locale, .portal-header-exit { background: #22324c; color: #fff; border: 1px solid #495872; border-radius: 8px; min-height: 40px; padding: 5px 9px; }
.portal-main { flex: 1; padding-block: clamp(24px, 4vw, 40px); }
.portal-footer { justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding-block: 12px; }
.portal-credit-link { color: var(--ink); font-weight: 650; text-underline-offset: .18em; }
.portal-credit-link:hover { color: var(--accent); }
.portal-intro { display: grid; gap: 7px; margin-bottom: 16px; }
.portal-course-top { align-items: start; justify-content: space-between; }
.portal-stack { display: grid; gap: 14px; }
.portal-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: clamp(16px, 3vw, 24px); }
.portal-narrow { max-width: 580px; margin-inline: auto; }
.portal-training { max-width: 760px; }
.portal-button { display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; font-weight: 650;
  padding: 7px 12px; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.portal-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.portal-button:hover { filter: brightness(.94); }
.portal-button:disabled { opacity: .6; cursor: wait; }
.portal-link { border: none; background: transparent; color: var(--accent); padding: 5px 0; font-weight: 650; }
.portal-status { border-radius: 6px; padding: 4px 8px; font-size: 13px; font-weight: 650; background: var(--canvas); color: var(--muted); }
.portal-status-progress { background: light-dark(#fff1d6, #382819); color: light-dark(#754604, #ffd69d); }
.portal-status-valid { background: light-dark(#e8f5ed, #17372d); color: light-dark(#146248, #a0e4c7); }
.portal-label { display: grid; gap: 5px; font-weight: 650; }
.portal-label input { padding: 10px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); }
.portal-error { margin-top: 16px; color: var(--accent); }
.certificate-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line);
  border-radius: 16px; overflow: auto; background: var(--paper); color: var(--ink); box-shadow: 0 24px 70px #0d182840; }
.certificate-dialog::backdrop { background: #0d1828b0; }
.certificate-dialog-head, .certificate-dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px;
  flex-wrap: wrap; padding: 14px clamp(14px, 4vw, 22px); }
.certificate-dialog-head h2 { margin-bottom: 3px; }
.certificate-dialog-head p, .certificate-dialog-foot p { font-size: 14px; }
.certificate-document { min-height: 9rem; display: grid; align-items: center; background: var(--canvas);
  border-block: 1px solid var(--line); padding: clamp(6px, 2.5vw, 20px); }
.certificate-preview-status { text-align: center; padding: 12px; }
.certificate-document iframe { display: block; width: 100%; height: min(57dvh, 560px); margin: auto; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; }
.certificate-dialog-foot { background: var(--paper); }
.certificate-dialog-foot .portal-primary { margin-inline-start: auto; }
@media (max-width: 490px) {
  .portal-brand { gap: 8px; }
  .tenant-brand { padding-inline-end: 8px; }
  .tenant-name { max-inline-size: 160px; }
  .tenant-logo, .academy-logo { max-inline-size: 116px; height: 34px; }
  .portal-label-name { font-size: 13px; }
  .certificate-dialog { max-height: calc(100dvh - 24px); }
  .certificate-dialog-head p { max-width: 24ch; }
  .certificate-dialog-foot { justify-content: end; }
  .certificate-dialog-foot p { margin-inline-end: auto; }
}
@media (pointer: coarse) {
  :is(.portal-button, .portal-link, .portal-locale, .portal-header-exit, .portal-label input) { min-height: 44px; }
  .portal-label input { font-size: 16px; }
}
