/* ═══════════════════════════════════════════════════════════════════════════
   Training provider portal
   ───────────────────────────────────────────────────────────────────────────
   The portal is an ordinary scrolling document, not the signed-in application
   shell. site.css pins that shell to the viewport, so the first job here is to
   undo those assumptions; the rest is the portal's own design language.

   Loaded AFTER site.css so these rules win at equal specificity.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Release the viewport lock ─────────────────────────────────────────────
   site.css sets `html { height: 100% }` and, at >=993px, `html, body {
   overflow: hidden }` so the app shell can own its own scroll areas. On a plain
   document that clips everything below the fold with no way to reach it — which
   is exactly what a long portal page is. Both axes are restated on both
   elements, and !important is used deliberately: the app rule lives inside a
   media query that will otherwise keep re-asserting itself at desktop widths. */
html {
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scroll-behavior: smooth;
}

body.portal {
    height: auto !important;
    min-height: 100vh;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    background: var(--portal-bg);
    color: var(--portal-text);
    /* Typeface is inherited from site.css so the portal matches the rest of the product. */
    line-height: 1.6;
    margin: 0;
}

/* ── Palette ──────────────────────────────────────────────────────────────── */
:root {
    --portal-navy: #10233f;
    --portal-blue: #1e40af;
    --portal-blue-600: #2563eb;
    --portal-blue-50: #eff4ff;
    --portal-amber: #f59e0b;
    --portal-green: #0f9d58;
    --portal-red: #dc2626;

    --portal-bg: #f5f7fa;
    --portal-surface: #ffffff;
    --portal-border: #e3e8ef;
    --portal-border-strong: #cfd6e0;
    --portal-text: #16202e;
    --portal-text-2: #526279;
    --portal-text-3: #8a97a8;

    --portal-radius: 14px;
    --portal-radius-sm: 9px;
    --portal-shadow: 0 1px 2px rgba(16, 35, 63, .05), 0 8px 24px -12px rgba(16, 35, 63, .16);
    --portal-shadow-lg: 0 20px 50px -24px rgba(16, 35, 63, .38);
}

/* ── Masthead ─────────────────────────────────────────────────────────────── */
.portal-masthead {
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.portal-masthead-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.portal-wordmark {
    font-size: 1.32rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--portal-blue);
    text-decoration: none;
    line-height: 1;
}
.portal-wordmark span { color: var(--portal-amber); }

.portal-wordmark-sub {
    display: block;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--portal-text-3);
    margin-top: 3px;
}

.portal-masthead-contact {
    font-size: .78rem;
    color: var(--portal-text-3);
    text-align: right;
}
.portal-masthead-contact strong { color: var(--portal-text-2); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.portal-hero {
    background: linear-gradient(135deg, #10233f 0%, #17325c 55%, #1e40af 100%);
    color: #fff;
}

.portal-hero-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 34px 24px 30px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 26px;
    flex-wrap: wrap;
}

.portal-hero h1 {
    /* site.css sets an explicit dark colour on every heading, which overrides the white this
       inherits from the hero — so it is restated here rather than left to inheritance. */
    color: #fff;
    font-size: 1.72rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
    line-height: 1.25;
}

.portal-hero-sub {
    margin: 7px 0 0;
    font-size: .9rem;
    color: rgba(255, 255, 255, .74);
}

.portal-hero-meta {
    display: flex;
    gap: 22px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.portal-hero-meta div span {
    display: block;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
}
.portal-hero-meta div strong {
    font-size: .95rem;
    font-weight: 600;
}

/* Status pill */
.portal-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 17px;
    border-radius: 999px;
    font-size: .84rem;
    font-weight: 650;
    background: rgba(255, 255, 255, .13);
    border: 1px solid rgba(255, 255, 255, .22);
    backdrop-filter: blur(4px);
    white-space: nowrap;
}
.portal-status::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.portal-status.is-approved { color: #6ee7b7; }
.portal-status.is-pending  { color: #fcd34d; }
.portal-status.is-rejected { color: #fca5a5; }
.portal-status.is-draft    { color: #93c5fd; }
.portal-status.is-suspended{ color: #cbd5e1; }

/* Completion ring */
.portal-ring { display: flex; align-items: center; gap: 13px; }
.portal-ring svg { transform: rotate(-90deg); flex: 0 0 auto; }
.portal-ring-track { stroke: rgba(255, 255, 255, .18); }
.portal-ring-fill  { stroke: #fcd34d; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.portal-ring-label { font-size: .74rem; color: rgba(255, 255, 255, .72); line-height: 1.35; }
.portal-ring-label strong { display: block; font-size: 1.06rem; color: #fff; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.portal-tabs {
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
    position: sticky;
    top: 61px;
    z-index: 1010;
}

.portal-tabs-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.portal-tabs-inner::-webkit-scrollbar { display: none; }

.portal-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 15px 16px 13px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--portal-text-2);
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.portal-tab:hover { color: var(--portal-blue); }
.portal-tab.active { color: var(--portal-blue); border-bottom-color: var(--portal-blue); }
.portal-tab .count {
    font-size: .7rem;
    font-weight: 700;
    background: var(--portal-blue-50);
    color: var(--portal-blue);
    border-radius: 999px;
    padding: 2px 8px;
    min-width: 22px;
    text-align: center;
}
.portal-tab.active .count { background: var(--portal-blue); color: #fff; }

/* ── Page body ────────────────────────────────────────────────────────────── */
.portal-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 24px 72px;
}

.portal-page-intro {
    margin-bottom: 22px;
}
.portal-page-intro h2 {
    font-size: 1.24rem;
    font-weight: 700;
    letter-spacing: -.015em;
    margin: 0 0 4px;
}
.portal-page-intro p {
    margin: 0;
    font-size: .89rem;
    color: var(--portal-text-2);
    max-width: 74ch;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.pcard {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    margin-bottom: 22px;
    overflow: hidden;
}

.pcard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--portal-border);
    flex-wrap: wrap;
}

.pcard-head h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .95rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.01em;
}

.pcard-head .icon-chip {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: var(--portal-blue-50);
    color: var(--portal-blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex: 0 0 auto;
}

.pcard-body { padding: 22px; }
.pcard-body.tight { padding: 16px 22px; }
.pcard-foot {
    padding: 15px 22px;
    background: #fafbfd;
    border-top: 1px solid var(--portal-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.pcard-hint {
    font-size: .83rem;
    color: var(--portal-text-2);
    margin: 0 0 18px;
}

/* ── Checklist ────────────────────────────────────────────────────────────── */
.portal-progress {
    height: 8px;
    border-radius: 999px;
    background: #e8edf4;
    overflow: hidden;
    margin-bottom: 18px;
}
.portal-progress > div {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--portal-blue-600), var(--portal-blue));
}
.portal-progress.is-complete > div { background: linear-gradient(90deg, #34d399, var(--portal-green)); }

.checklist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 11px;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 12px 14px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    background: #fcfdff;
    font-size: .855rem;
}
.checklist-item.done { background: #f3fbf6; border-color: #cdebd9; }
.checklist-item.todo { border-color: #f2dcb4; background: #fffbf3; }

.checklist-item i { font-size: 1rem; margin-top: 1px; flex: 0 0 auto; }
.checklist-item.done i { color: var(--portal-green); }
.checklist-item.todo i { color: #c2740b; }
.checklist-item.optional i { color: var(--portal-text-3); }

.checklist-item .label { font-weight: 600; }
.checklist-item.done .label { font-weight: 500; color: var(--portal-text-2); }
.checklist-item .hint { display: block; font-size: .76rem; color: var(--portal-text-3); margin-top: 2px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.ptable-wrap { overflow-x: auto; }
.ptable {
    width: 100%;
    border-collapse: collapse;
    font-size: .865rem;
}
.ptable thead th {
    text-align: left;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--portal-text-3);
    padding: 11px 18px;
    background: #fafbfd;
    border-bottom: 1px solid var(--portal-border);
    white-space: nowrap;
}
.ptable tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid #f0f3f7;
    vertical-align: top;
}
.ptable tbody tr:last-child td { border-bottom: none; }
.ptable tbody tr:hover { background: #fbfcfe; }
.ptable .t-title { font-weight: 650; }
.ptable .t-sub { font-size: .755rem; color: var(--portal-text-3); margin-top: 2px; }
.ptable .t-actions { text-align: right; white-space: nowrap; }

/* ── Pills ────────────────────────────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .715rem;
    font-weight: 650;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.4;
}
.pill-green  { background: #e7f7ee; color: #0b7a45; }
.pill-amber  { background: #fef4e2; color: #9a6207; }
.pill-red    { background: #fdeaea; color: #b91c1c; }
.pill-blue   { background: var(--portal-blue-50); color: var(--portal-blue); }
.pill-grey   { background: #eef1f5; color: #5b6879; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.pbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: .855rem;
    font-weight: 650;
    padding: 9px 17px;
    border-radius: var(--portal-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    line-height: 1.4;
}
.pbtn:disabled, .pbtn.disabled { opacity: .55; cursor: not-allowed; }

.pbtn-primary { background: var(--portal-blue); color: #fff; }
.pbtn-primary:hover:not(:disabled) { background: #1a389c; color: #fff; box-shadow: 0 6px 16px -8px rgba(30,64,175,.8); }

.pbtn-ghost { background: #fff; color: var(--portal-text-2); border-color: var(--portal-border-strong); }
.pbtn-ghost:hover { background: #f6f8fb; color: var(--portal-text); }

.pbtn-danger { background: #fff; color: var(--portal-red); border-color: #f3c8c8; }
.pbtn-danger:hover { background: #fdf2f2; }

.pbtn-sm { font-size: .78rem; padding: 6px 11px; gap: 5px; }
.pbtn-icon { padding: 6px 9px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.pfield { margin-bottom: 0; }
.pfield label,
.plabel {
    display: block;
    font-size: .775rem;
    font-weight: 650;
    color: var(--portal-text-2);
    margin-bottom: 6px;
    letter-spacing: .005em;
}
.plabel .req { color: var(--portal-red); }

.pform-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-8  { grid-column: span 8; }
.col-12 { grid-column: span 12; }

@media (max-width: 780px) {
    .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
}

.pinput,
.portal-wrap .form-control,
.portal-wrap .form-select,
.modal .form-control,
.modal .form-select {
    width: 100%;
    font-size: .875rem;
    padding: 9px 12px;
    border: 1px solid var(--portal-border-strong);
    border-radius: var(--portal-radius-sm);
    background: #fff;
    color: var(--portal-text);
    transition: border-color .15s, box-shadow .15s;
}
.pinput:focus,
.portal-wrap .form-control:focus,
.portal-wrap .form-select:focus,
.modal .form-control:focus,
.modal .form-select:focus {
    outline: none;
    border-color: var(--portal-blue-600);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.pinput:disabled, .portal-wrap .form-control:disabled { background: #f4f6f9; color: var(--portal-text-3); }

.phelp { font-size: .755rem; color: var(--portal-text-3); margin-top: 5px; }

.pfieldset-head {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--portal-text-3);
    margin: 30px 0 15px;
    padding-top: 20px;
    border-top: 1px solid var(--portal-border);
}
.pfieldset-head:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.pfieldset-head .optional {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--portal-text-3);
}

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.palert {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 18px;
    border-radius: var(--portal-radius-sm);
    font-size: .865rem;
    margin-bottom: 20px;
    border: 1px solid;
}
.palert i { font-size: 1.05rem; margin-top: 1px; flex: 0 0 auto; }
.palert-success { background: #f0fbf4; border-color: #c5e9d4; color: #0b6b3d; }
.palert-warning { background: #fffaf0; border-color: #f5dcae; color: #8a5a06; }
.palert-danger  { background: #fef4f4; border-color: #f5c9c9; color: #a51f1f; }
.palert-info    { background: var(--portal-blue-50); border-color: #c9dbfb; color: #1d3d94; }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.pempty {
    text-align: center;
    padding: 46px 24px;
}
.pempty-icon {
    width: 58px; height: 58px;
    margin: 0 auto 14px;
    border-radius: 16px;
    background: var(--portal-blue-50);
    color: var(--portal-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.pempty h4 { font-size: 1rem; font-weight: 700; margin: 0 0 6px; }
.pempty p {
    font-size: .855rem;
    color: var(--portal-text-2);
    max-width: 52ch;
    margin: 0 auto 18px;
}

/* ── Stat strip ───────────────────────────────────────────────────────────── */
.pstats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.pstat {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 16px 18px;
    box-shadow: var(--portal-shadow);
}
.pstat .v { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.pstat .k {
    font-size: .69rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--portal-text-3);
    margin-top: 4px;
}

/* ── Dialogs ──────────────────────────────────────────────────────────────── */
/* The dialog is pinned to the viewport and the body scrolls inside it, so the
   header and the Save/Cancel footer stay reachable however tall the form is.
   min-height:0 is the part that makes it work: a flex item defaults to
   min-height:auto and refuses to shrink below its content, so without it the
   surplus is simply clipped and no scrollbar ever appears. */
.modal { overflow-y: auto; }

.modal-dialog {
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
}

.modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
    border: none;
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow-lg);
    overflow: hidden;
}

.modal-header {
    flex: 0 0 auto;
    padding: 18px 22px;
    border-bottom: 1px solid var(--portal-border);
    background: #fff;
}
.modal-title { font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 22px;
}

.modal-footer {
    flex: 0 0 auto;
    padding: 15px 22px;
    border-top: 1px solid var(--portal-border);
    background: #fafbfd;
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

/* Dialog tab strip */
.modal .nav-tabs {
    flex: 0 0 auto;
    padding: 0 22px;
    border-bottom: 1px solid var(--portal-border);
    background: #fff;
    gap: 2px;
}
.modal .nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-size: .84rem;
    font-weight: 650;
    color: var(--portal-text-2);
    padding: 12px 14px;
}
.modal .nav-tabs .nav-link.active {
    color: var(--portal-blue);
    border-bottom-color: var(--portal-blue);
    background: none;
}

/* ── Upload dropzone ──────────────────────────────────────────────────────── */
.pdrop {
    border: 1.5px dashed var(--portal-border-strong);
    border-radius: var(--portal-radius-sm);
    padding: 18px;
    background: #fbfcfe;
    text-align: center;
}
.pdrop i { font-size: 1.5rem; color: var(--portal-blue); }
.pdrop p { font-size: .82rem; color: var(--portal-text-2); margin: 8px 0 12px; }

/* ── Steps list ───────────────────────────────────────────────────────────── */
.psteps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 18px; }
.psteps li {
    counter-increment: step;
    position: relative;
    padding-left: 34px;
    margin-bottom: 11px;
    font-size: .865rem;
    color: var(--portal-text-2);
}
.psteps li::before {
    content: counter(step);
    position: absolute;
    left: 0; top: 0;
    width: 23px; height: 23px;
    border-radius: 50%;
    background: var(--portal-blue-50);
    color: var(--portal-blue);
    font-size: .73rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.portal-footer {
    border-top: 1px solid var(--portal-border);
    background: var(--portal-surface);
    padding: 22px 24px;
    text-align: center;
    font-size: .785rem;
    color: var(--portal-text-3);
}
.portal-footer strong { color: var(--portal-text-2); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
    .portal-hero-inner { padding: 26px 20px 24px; }
    .portal-hero h1 { font-size: 1.4rem; }
    .portal-wrap { padding: 22px 16px 60px; }
    .portal-masthead-inner, .portal-tabs-inner { padding-left: 16px; padding-right: 16px; }
    .pcard-body { padding: 18px; }
    .portal-masthead-contact { display: none; }
    .portal-tabs { top: 57px; }
}

@media (max-width: 576px) {
    .modal-dialog { margin: .5rem; max-height: calc(100vh - 1rem); }
    .modal-content { max-height: calc(100vh - 1rem); }
    .portal-tab { padding: 13px 11px; font-size: .82rem; }
}

/* ── Confirmation dialog ──────────────────────────────────────────────────── */
.pconfirm-icon {
    width: 56px; height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #fdeaea;
    color: var(--portal-red);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}

.pconfirm-message {
    font-size: .95rem;
    font-weight: 600;
    color: var(--portal-text);
    margin: 0;
    line-height: 1.5;
}

/* Solid destructive button, for the moment of commitment only — the ghost variant is for the
   repeatable row actions that open this dialog in the first place. */
.pbtn-danger-solid { background: var(--portal-red); color: #fff; border-color: var(--portal-red); }
.pbtn-danger-solid:hover { background: #b91c1c; color: #fff; }
