/**
 * UKSE Partner Portal Styles
 *
 * @package LSE_Clean_AFS
 * @since 1.21.0
 */

/* =============================================================================
   Hero
   ============================================================================= */

.ukse-portal-hero {
    background: linear-gradient(to right, #000032, #6ACAF3);
    padding: 80px 0;
    margin-bottom: 0;
    position: relative;
}

.ukse-portal-hero .ukse-schools-hero__wrap {
    position: relative;
    z-index: 1;
}

.ukse-portal-hero .ukse-schools-hero__title {
    color: #ffffff;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.ukse-portal-hero .ukse-schools-hero__intro {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.15rem;
    max-width: 600px;
}

.ukse-portal-hero .ukse-schools-hero__intro p {
    margin: 0;
}

/* Hero image container */
.ukse-portal-hero .ukse-schools-hero__media {
    position: relative;
    z-index: 1;
}

.ukse-portal-hero .ukse-schools-hero__media img {
    height: 300px;
    width: auto;
    object-fit: contain;
}

/* =============================================================================
   Portal Section
   ============================================================================= */

.portal-section {
    padding: 60px 0;
    background: #f7f9fc;
    min-height: 60vh;
}

.portal-content {
    max-width: 100%;
}

/* =============================================================================
   Portal Cards
   ============================================================================= */

.portal-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(0, 0, 50, 0.08);
    padding: 40px;
    max-width: 720px;
    margin: 0 auto;
}

.portal-card h2 {
    color: var(--lse-dark-blue, #000032);
    font-size: 1.75rem;
    margin: 0 0 0.75rem;
}

.portal-card > p {
    color: #4b5563;
    line-height: 1.7;
    margin-bottom: 2rem;
}

.portal-card--request {
    max-width: 560px;
}

.portal-card--submit {
    max-width: 800px;
}

.portal-card--success {
    text-align: center;
    max-width: 560px;
}

.portal-card--success h2 {
    color: #059669;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: rgba(5, 150, 105, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon svg {
    width: 40px;
    height: 40px;
    color: #059669;
}

/* =============================================================================
   Portal Messages
   ============================================================================= */

.portal-message {
    padding: 16px 20px;
    border-radius: 10px;
    margin-top: 1.5rem;
}

.portal-message h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.portal-message p {
    margin: 0;
}

.portal-message--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.portal-message--error h2 {
    color: #991b1b;
}

.portal-message--success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.portal-message--warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.portal-message--info {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1e40af;
    margin-top: 1rem;
}

/* Admin debug panel */
.admin-debug-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.admin-debug-panel > p {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: #475569;
}

.debug-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.debug-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.debug-table td:first-child {
    font-weight: 500;
    color: #64748b;
    width: 40%;
}

.debug-table .status-ok {
    color: #059669;
    font-weight: 600;
}

.debug-table .status-fail {
    color: #dc2626;
    font-weight: 600;
}

/* Admin debug link fallback */
.admin-debug-link {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed #cbd5e1;
}

.admin-debug-link p {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.admin-debug-link input[type="text"] {
    width: 100%;
    padding: 8px;
    margin: 8px 0;
    font-family: monospace;
    font-size: 0.8rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.admin-debug-link .home-button--small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.mail-error-detail {
    margin-top: 0.75rem;
    color: #6b7280;
}

/* =============================================================================
   Portal Form
   ============================================================================= */

.portal-form {
    margin-top: 1.5rem;
}

.portal-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 2rem;
}

.portal-fieldset legend {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--lse-dark-blue, #000032);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid rgba(230, 0, 126, 0.2);
    width: 100%;
}

.portal-form__field {
    margin-bottom: 1.5rem;
}

.portal-form__field--half {
    max-width: 50%;
}

.portal-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.portal-form__field label {
    display: block;
    font-weight: 600;
    color: var(--lse-dark-blue, #000032);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.portal-form__field label .required {
    color: #e6007e;
}

.portal-form__field label .optional {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.85rem;
}

.portal-form__field input[type="text"],
.portal-form__field input[type="email"],
.portal-form__field input[type="url"],
.portal-form__field input[type="tel"],
.portal-form__field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
}

.portal-form__field input:focus,
.portal-form__field textarea:focus {
    outline: none;
    border-color: #e6007e;
    box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.1);
}

.portal-form__field input::placeholder,
.portal-form__field textarea::placeholder {
    color: #9ca3af;
}

/* Readonly field styling */
.portal-form__field input[readonly],
.portal-form__field--readonly {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.portal-form__field input[readonly]:focus {
    border-color: #e5e7eb;
    box-shadow: none;
}

.portal-form__field textarea {
    resize: vertical;
    min-height: 120px;
}

.portal-form__field input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.portal-form__field input[type="file"]:hover {
    border-color: #e6007e;
    background: rgba(230, 0, 126, 0.02);
}

.portal-form__field input[type="file"]:focus {
    outline: none;
    border-color: #e6007e;
}

.field-hint {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0.5rem 0 0;
}

.gallery-count {
    font-size: 0.9rem;
    color: var(--lse-dark-blue, #000032);
    font-weight: 500;
    margin: 0.5rem 0 0;
}

.gallery-count.error {
    color: #dc2626;
}

/* =============================================================================
   Current Media Preview
   ============================================================================= */

.current-media {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f3f4f6;
    border-radius: 10px;
}

.current-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0 0 0.75rem;
}

.current-media img {
    border-radius: 6px;
    max-height: 80px;
    width: auto;
}

.gallery-thumbs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.gallery-thumbs img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.more-count {
    background: #e5e7eb;
    color: #4b5563;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Editable gallery with remove controls */
.gallery-thumbs--editable {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.gallery-thumb-item {
    position: relative;
    display: inline-block;
}

.gallery-thumb-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    transition: opacity 0.2s;
}

.gallery-thumb-item:has(input:checked) img {
    opacity: 0.4;
}

.current-media__item {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.remove-media {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #dc2626;
    user-select: none;
}

.remove-media input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.gallery-thumb-item .remove-media {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.gallery-thumb-item .remove-media input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.gallery-thumb-item .remove-media span {
    line-height: 1;
}

/* =============================================================================
   Form Actions
   ============================================================================= */

.portal-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.portal-form__actions .home-button {
    min-width: 200px;
    border-radius: 50px;
}

/* Outline button: white text on hover with gradient background */
.portal-form__actions .home-button--outline:hover,
.portal-form__actions .home-button--outline:focus,
.portal-step__nav .home-button--outline:hover,
.portal-step__nav .home-button--outline:focus {
    background: linear-gradient(135deg, #EE7218 0%, #E6007E 100%) !important;
    color: #ffffff !important;
    border-color: transparent;
}

.portal-form__actions .home-button .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-form__actions .home-button.is-loading .btn-text {
    display: none;
}

.portal-form__actions .home-button.is-loading .btn-loading {
    display: inline-flex !important;
}

/* =============================================================================
   Validation States
   ============================================================================= */

.portal-form__field.has-error input,
.portal-form__field.has-error textarea,
.portal-form__field.has-error select {
    border-color: #dc2626;
    background-color: #fef2f2;
}

.portal-form__field.has-error .field-error {
    display: block;
}

.field-error {
    display: none;
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* =============================================================================
   Form Error Banner (prominent, top of form)
   ============================================================================= */

.ukse-form-error {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 2px solid #dc2626;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

.ukse-form-error__icon {
    flex-shrink: 0;
    font-size: 1.75rem;
    line-height: 1;
    color: #dc2626;
}

.ukse-form-error__content {
    flex: 1;
}

.ukse-form-error__content strong {
    display: block;
    font-size: 1.1rem;
    color: #991b1b;
    margin-bottom: 0.35rem;
}

.ukse-form-error__content p {
    margin: 0;
    font-size: 0.95rem;
    color: #b91c1c;
    line-height: 1.5;
}

.ukse-form-error__list {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
    color: #b91c1c;
    line-height: 1.6;
}

.ukse-form-error__list li {
    margin-bottom: 0.25rem;
}

.ukse-form-error__list li:last-child {
    margin-bottom: 0;
}

/* =============================================================================
   Inline Field Error (next to specific field)
   ============================================================================= */

.ukse-field-error {
    display: block;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    border-radius: 0 6px 6px 0;
    color: #991b1b;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

/* =============================================================================
   Field Error Highlight (has-error enhancements)
   ============================================================================= */

.portal-form__field.has-error {
    position: relative;
}

.portal-form__field.has-error input[type="file"] {
    border-color: #dc2626;
    background: #fef2f2;
}

.portal-form__field.has-error .current-media,
.portal-form__field.has-error .new-media-preview {
    border-color: #dc2626;
    background: #fef2f2;
}

/* Pulse animation to draw attention */
.ukse-field-pulse {
    animation: ukse-pulse 0.5s ease-in-out 2;
}

@keyframes ukse-pulse {
    0%, 100% {
        box-shadow: none;
    }
    50% {
        box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.3);
    }
}

/* =============================================================================
   New Media Previews (client-side)
   ============================================================================= */

.new-media-preview {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f0fdf4;
    border: 1px dashed #86efac;
    border-radius: 10px;
}

.new-media-preview .current-label {
    color: #166534;
    font-weight: 500;
}

.new-media-preview .preview-content {
    margin-top: 0.5rem;
}

.new-media-preview .gallery-thumb-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.remove-preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: background 0.2s, color 0.2s;
}

.remove-preview-btn:hover {
    background: #dc2626;
    color: #fff;
}

/* Gallery preview remove button (positioned on thumbnail) */
.new-gallery-preview .gallery-thumb-item {
    position: relative;
    display: inline-block;
}

.new-gallery-preview .gallery-thumb-item .remove-preview-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

/* =============================================================================
   Email Change Request
   ============================================================================= */

.email-change-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #e6007e;
    text-decoration: none;
}

.email-change-link:hover {
    text-decoration: underline;
}

.email-change-fields {
    margin-top: 1rem;
    padding: 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}

.email-change-fields .portal-form__field {
    margin-bottom: 1rem;
}

.email-change-fields .portal-form__field:last-child {
    margin-bottom: 0;
}

.email-change-fields textarea {
    min-height: 60px;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .ukse-portal-hero {
        padding: 40px 0;
    }

    .ukse-portal-hero .ukse-schools-hero__title {
        font-size: 2rem;
    }

    .portal-section {
        padding: 40px 0;
    }

    .portal-card {
        padding: 24px;
        border-radius: 14px;
    }

    .portal-card h2 {
        font-size: 1.5rem;
    }

    .portal-form__row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .portal-form__field--half {
        max-width: 100%;
    }

    .portal-fieldset legend {
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .portal-card {
        padding: 20px 16px;
    }

    .current-media {
        padding: 0.75rem;
    }

    .gallery-thumbs img {
        width: 50px;
        height: 50px;
    }
}

/* Gallery error badge */
.gallery-thumb-item.has-error {
    position: relative;
    border: 2px solid #e74c3c;
    border-radius: 6px;
}
.gallery-error-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Gallery error text (shows actual reasons, not generic text) */
.gallery-error-helper {
    font-size: 0.9rem;
    color: #b91c1c;
    margin: 0.5rem 0 0.75rem;
    padding: 8px 12px;
    background: #fef2f2;
    border-left: 3px solid #e74c3c;
    border-radius: 0 4px 4px 0;
    line-height: 1.5;
}

/* ====== PHASE 2.1: COLLAPSIBLE FIELDSETS & DESCRIPTION SECTIONS ====== */

/* Collapsible fieldset toggle */
.portal-fieldset--collapsible legend {
    width: 100%;
}

.fieldset-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fieldset-toggle:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.toggle-icon {
    font-size: 1.25rem;
    font-weight: bold;
    color: #6b7280;
}

.fieldset-content {
    padding-top: 1.25rem;
}

.fieldset-intro {
    color: #6b7280;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

/* Optional fieldset styling — subtle solid pastel body + highlighted header */
.portal-fieldset--optional {
    background: #F6FBFF;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-top: 0.5rem;
}

.portal-fieldset--optional > legend {
    width: 100%;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

/* Header bar: solid pastel (slightly stronger than body) */
.portal-fieldset--optional .fieldset-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #E7F3FF;
    border: 1px solid #D6E9F8;
    border-radius: 12px;
    padding: 12px 16px;
}

.portal-fieldset--optional .fieldset-toggle:hover {
    background: #DDEEFF;
}

/* Keep icon alignment */
.portal-fieldset--optional .toggle-icon {
    margin-left: 12px;
}

/* Three-column row for key info fields */
.portal-form__row--thirds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .portal-form__row--thirds {
        grid-template-columns: 1fr;
    }
}

/* Divider */
.portal-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.5rem 0;
}

/* Description sections container */
.description-sections {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.description-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.section-number {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.remove-section {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.remove-section:hover {
    color: #ef4444;
}

/* Checkbox field styling */
.portal-form__field--checkbox {
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.95rem;
    color: #374151;
}

/* Secondary button style for Add Section */
.portal-btn--secondary {
    background: transparent;
    border: 1px dashed #9ca3af;
    color: #6b7280;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.portal-btn--secondary:hover {
    border-color: #6b7280;
    color: #374151;
    background: #f9fafb;
}

/* ====== PHASE 2.1.1: PROFILE COMPLETION BAR ====== */

.ukse-profile-completion {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.completion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.completion-label {
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
}

.completion-count {
    font-size: 0.85rem;
    color: #6b7280;
}

.completion-bar-wrapper {
    background: #e5e7eb;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.completion-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease, background-color 0.3s ease;
}

.completion-bar--low {
    background: linear-gradient(90deg, #ef4444, #f97316);
}

.completion-bar--medium {
    background: linear-gradient(90deg, #f97316, #eab308);
}

.completion-bar--complete {
    background: linear-gradient(90deg, #22c55e, #10b981);
}

.completion-percent {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    text-align: right;
}

.completion-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.completion-note {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 0.75rem 0;
}

.completion-missing-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.completion-missing-list li {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #fcd34d;
}

.completion-missing-list .completion-more {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #d1d5db;
}

/* ====== COUNTER BASE STYLES ====== */
/* Unified counter styling for char/word counters */

.char-counter,
.word-counter {
    font-size: 0.8rem;
    color: #6b7280;
    transition: color 0.2s ease;
}

.char-counter {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.25rem;
    margin-top: 4px;
}

.char-counter--inline {
    margin-top: 2px;
}

.word-counter {
    display: inline;
}

/* Counter value styling (shared) */
.char-counter .char-count,
.word-counter .word-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

/* ====== COUNTER STATE: NEUTRAL (default) ====== */
.char-counter .char-count,
.word-counter .word-count {
    color: #6b7280;
}

/* ====== COUNTER STATE: OK (meeting minimum/target) ====== */
.char-counter--ok .char-count,
.word-counter--ok .word-count {
    color: #10b981;
}

/* ====== COUNTER STATE: WARNING (approaching limit or below recommended) ====== */
.char-counter--warning .char-count,
.word-counter--warning .word-count {
    color: #f59e0b;
}

/* ====== COUNTER STATE: ERROR (over limit or under minimum) ====== */
.char-counter--over .char-count,
.word-counter--under .word-count {
    color: #dc2626;
}

/* ====== COUNTER LAYOUT VARIANTS ====== */

/* Section word counter within char-counter line */
.section-word-counter {
    margin-left: 0;
}

/* Courses overview word counter (standalone block) */
.courses-word-counter {
    display: block;
    margin-top: 4px;
    text-align: right;
}

/* ====== PHASE 3: STEPPER PAGINATION ====== */

/* Stepper Navigation Header */
.portal-stepper {
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.portal-stepper__steps {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.portal-stepper__step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.portal-stepper__step:hover:not(.portal-stepper__step--active) {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.portal-stepper__step--active {
    background: linear-gradient(135deg, rgba(230, 0, 126, 0.08) 0%, rgba(238, 114, 24, 0.08) 100%);
    border-color: #e6007e;
}

.portal-stepper__step--completed {
    background: #ecfdf5;
    border-color: #10b981;
}

.step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.portal-stepper__step--active .step-number {
    background: linear-gradient(135deg, #e6007e 0%, #EE7218 100%);
    color: #ffffff;
}

.portal-stepper__step--completed .step-number {
    background: #10b981;
    color: #ffffff;
}

.portal-stepper__step--completed .step-number::before {
    content: "✓";
}

.step-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
}

.portal-stepper__step--active .step-label {
    color: #e6007e;
}

.portal-stepper__step--completed .step-label {
    color: #059669;
}

/* Step Containers - increased specificity for cross-browser consistency */
.portal-form .portal-step {
    display: none !important;
}

.portal-form .portal-step.portal-step--active {
    display: block !important;
    animation: stepFadeIn 0.3s ease;
}

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Step Navigation Buttons */
.portal-step__nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.portal-step__nav .home-button {
    min-width: 180px;
}

.portal-nav-prev:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form Actions - always visible at bottom */
.portal-form__actions {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    z-index: 10;
    padding: 1.5rem 0;
    margin-top: 2rem;
    border-top: none;
    box-shadow: none;
}

/* Submit button disabled state */
#portal-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #9ca3af;
}

#portal-submit-btn:disabled:hover {
    background: #9ca3af;
}

/* Responsive Stepper */
@media (max-width: 768px) {
    .portal-stepper__steps {
        flex-direction: column;
        gap: 0.75rem;
    }

    .portal-stepper__step {
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .step-number {
        margin-bottom: 0;
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .step-label {
        text-align: left;
    }

    .portal-step__nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .portal-step__nav .home-button {
        width: 100%;
    }
}

/* =============================================================================
   F1.7+: Portal Choice Screen & Section Routing
   ============================================================================= */

/* Choice Screen Card */
.portal-card--choice {
    text-align: center;
    padding: 2rem;
    max-width: 540px;
}

.portal-card--choice h2 {
    font-size: 1.75rem;
    color: #111827;
    margin-bottom: 0.5rem;
}

.portal-choice__intro {
    color: #6b7280;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Choice Option Cards */
.portal-choice__options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.portal-choice__option {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    gap: 1.25rem;
    width: 100%;
}

.portal-choice__option:hover,
.portal-choice__option:focus {
    border-color: #f97316;
    background: #fff;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
    text-decoration: none;
}

.portal-choice__icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-choice__icon--analytics {
    background: #dbeafe;
    color: #2563eb;
}

.portal-choice__icon--profile {
    background: #fef3c7;
    color: #d97706;
}

.portal-choice__option:hover .portal-choice__icon--analytics {
    background: #2563eb;
    color: #fff;
}

.portal-choice__option:hover .portal-choice__icon--profile {
    background: #d97706;
    color: #fff;
}

.portal-choice__text {
    text-align: left;
}

.portal-choice__label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
}

.portal-choice__desc {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Back Link */
.portal-back-link {
    display: inline-block;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: color 0.2s ease;
}

.portal-back-link:hover {
    color: #f97316;
    text-decoration: none;
}

/* Analytics View (Full Page) */
.portal-card--analytics-view {
    padding: 2rem;
}

.portal-analytics-header {
    margin-bottom: 1rem;
}

.portal-card--analytics-view h2 {
    font-size: 1.5rem;
    color: #111827;
    margin-bottom: 0.5rem;
}

.portal-card--analytics-view > p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Expanded analytics (no toggle needed) */
.portal-analytics--expanded {
    border: none;
    margin-bottom: 0;
    background: transparent;
}

.portal-analytics--expanded .portal-analytics__content {
    display: block !important;
}

.portal-analytics-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

/* Profile Header (Back Link) */
.portal-profile-header {
    margin-bottom: 0.5rem;
}

/* =============================================================================
   F1.7: Partner Portal Lead Analytics Section
   ============================================================================= */

.portal-analytics {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.portal-analytics__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
}

.portal-analytics__header:hover {
    background: #f3f4f6;
}

.portal-analytics__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

.portal-analytics__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.portal-analytics__toggle:hover {
    color: #1f2937;
    background: #e5e7eb;
}

.portal-analytics__toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.portal-analytics__content {
    padding: 1.25rem;
}

.portal-analytics__content[hidden] {
    display: none;
}

/* Empty State */
.portal-analytics__empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.portal-analytics__empty p {
    margin: 0 0 0.5rem 0;
}

.portal-analytics__empty p:last-child {
    margin-bottom: 0;
}

.portal-analytics__hint {
    font-size: 0.875rem;
    color: #9ca3af;
}

.portal-analytics__error {
    color: #dc2626;
    background: #fef2f2;
    padding: 1rem;
    border-radius: 4px;
    margin: 0;
}

/* Stat Cards */
.portal-analytics__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal-stat {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
}

.portal-stat__value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #000032;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.portal-stat__label {
    display: block;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* Monthly Chart */
.portal-analytics__chart {
    margin-bottom: 1.5rem;
}

.portal-analytics__subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 1rem 0;
}

.portal-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.25rem;
    height: 120px;
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem 0.5rem 0.5rem 0.5rem;
    overflow-x: auto;
}

.portal-chart__bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 40px;
    height: 100%;
}

.portal-chart__bar {
    width: 100%;
    max-width: 30px;
    background: linear-gradient(180deg, #6ACAF3 0%, #000032 100%);
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 4px;
    transition: height 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.portal-chart__bar-value {
    position: absolute;
    top: -20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #1f2937;
}

.portal-chart__label {
    font-size: 0.65rem;
    color: #6b7280;
    margin-top: 0.25rem;
    white-space: nowrap;
}

/* Breakdown Tables */
.portal-analytics__breakdowns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.portal-analytics__breakdown {
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem;
}

.portal-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.portal-breakdown-table thead th {
    text-align: left;
    font-weight: 600;
    color: #374151;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.portal-breakdown-table thead th:last-child {
    text-align: right;
}

.portal-breakdown-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    color: #4b5563;
}

.portal-breakdown-table tbody td:last-child {
    text-align: right;
    font-weight: 600;
    color: #1f2937;
}

.portal-breakdown-table tbody tr:last-child td {
    border-bottom: none;
}

/* Privacy Note */
.portal-analytics__privacy {
    font-size: 0.8rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.portal-analytics__privacy strong {
    color: #374151;
}

.portal-analytics__updated {
    margin: 0;
    color: #9ca3af;
    font-size: 0.75rem;
    text-align: right;
}

/* Responsive Analytics */
@media (max-width: 768px) {
    .portal-analytics__stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .portal-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
    }

    .portal-stat__value {
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .portal-analytics__breakdowns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .portal-chart {
        min-width: 500px;
    }

    .portal-analytics__chart {
        overflow-x: auto;
    }
}

/* =============================================================================
   F1.8 Quota Widget (Pass 2B)
   ============================================================================= */

.portal-quota {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.portal-quota__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.portal-quota__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0c4a6e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-quota__status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #dcfce7;
    color: #166534;
}

.portal-quota__status--warning {
    background: #fef3c7;
    color: #92400e;
}

.portal-quota__status--critical {
    background: #fee2e2;
    color: #991b1b;
}

.portal-quota__status--reached {
    background: #fecaca;
    color: #7f1d1d;
}

.portal-quota__stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
}

.portal-quota__stat {
    flex: 1;
}

.portal-quota__stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0369a1;
    line-height: 1;
}

.portal-quota__stat-label {
    display: block;
    font-size: 0.75rem;
    color: #0c4a6e;
    margin-top: 0.15rem;
}

.portal-quota__bar {
    height: 8px;
    background: #bae6fd;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.portal-quota__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9 0%, #0369a1 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.portal-quota__bar-fill--warning {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.portal-quota__bar-fill--critical,
.portal-quota__bar-fill--reached {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.portal-quota__trial {
    font-size: 0.8rem;
    color: #0c4a6e;
    padding-top: 0.5rem;
    border-top: 1px dashed #bae6fd;
}

.portal-quota__trial strong {
    color: #0369a1;
}

/* Quota Widget in Analytics Expanded View */
.portal-analytics--expanded .portal-quota {
    margin-top: 1rem;
}

/* =============================================================================
   Partner Terms Acceptance
   ============================================================================= */

.portal-fieldset--terms {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    padding-top: 0;
    margin-top: 2rem;
}

.portal-fieldset--terms legend {
    font-size: 1rem;
    padding: 1.25rem 0 0.5rem;
    margin-bottom: 1rem;
    background: #f9fafb;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    border-radius: 12px 12px 0 0;
}

/* Terms accepted state */
.portal-terms__accepted {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #15803d;
    font-size: 0.95rem;
    margin: 0;
}

.portal-terms__check-icon {
    flex-shrink: 0;
    stroke: #16a34a;
}

.portal-terms__accepted strong {
    color: #166534;
}

/* Terms checkbox field */
.portal-form__field--terms {
    margin-bottom: 0;
}

.portal-form__field--terms .checkbox-label {
    font-size: 0.95rem;
    line-height: 1.5;
}

.portal-form__field--terms .checkbox-label span {
    display: inline;
}

.portal-form__field--terms .checkbox-label a {
    color: var(--lse-primary-orange, #FF6B00);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.portal-form__field--terms .checkbox-label a:hover {
    color: #e55a00;
}

/* Validation error styling for terms checkbox */
.portal-form__field--terms.has-error .checkbox-label {
    color: #dc2626;
}

.portal-form__field--terms.has-error input[type="checkbox"] {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* =============================================================================
   Portal Account Info (Tier + Entitlement Display)
   ============================================================================= */

.portal-analytics__account-info {
    margin-bottom: 1.25rem;
    padding: 0.875rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.portal-account-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
}

.portal-account-info__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-account-info__label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.portal-account-info__value {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

/* Tier value colors */
.portal-account-info__value--tier-standard_free {
    color: #475569;
    background: #f1f5f9;
}

.portal-account-info__value--tier-silver {
    color: #374151;
    background: #e5e7eb;
}

.portal-account-info__value--tier-gold {
    color: #92400e;
    background: #fef3c7;
}

.portal-account-info__value--tier-platinum {
    color: #1e3a5f;
    background: #e0e7ff;
}

/* Entitlement value colors */
.portal-account-info__value--entitlement-none {
    color: #6b7280;
    background: #f3f4f6;
}

.portal-account-info__value--entitlement-trial_active {
    color: #1e40af;
    background: #dbeafe;
}

.portal-account-info__value--entitlement-trial_expired {
    color: #b91c1c;
    background: #fee2e2;
}

.portal-account-info__value--entitlement-paid_active {
    color: #15803d;
    background: #dcfce7;
}

@media (max-width: 480px) {
    .portal-account-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* =============================================================================
   Portal Login Link Contrast (Request Link Screen)
   ============================================================================= */

.portal-card--request a,
.portal-card--request .field-hint a {
    color: var(--lse-primary-orange, #FF6B00);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.portal-card--request a:hover,
.portal-card--request .field-hint a:hover {
    color: #e55a00;
    text-decoration-thickness: 2px;
}

.portal-card--request a:focus,
.portal-card--request .field-hint a:focus {
    outline: 2px solid var(--lse-primary-orange, #FF6B00);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Improve field hint link visibility within login form */
.portal-card--request .field-hint {
    color: #4b5563;
}

/* For Schools link in hero - Phase 1 linking */
.ukse-schools-hero__for-schools-link {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
}

.ukse-schools-hero__for-schools-link a {
    color: #ffffff;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.ukse-schools-hero__for-schools-link a:hover {
    color: #ffffff;
    text-decoration-thickness: 2px;
}

/* =============================================================================
   Portal Hint Box (subtle info styling for helper text)
   ============================================================================= */

.portal-card--request .field-hint.portal-hint-box {
    display: block;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #94a3b8;
    border-radius: 0 10px 10px 0;
    padding: 12px 14px;
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #4b5563;
}

.portal-card--request .field-hint.portal-hint-box br {
    display: block;
    content: "";
    margin-bottom: 0.35rem;
}

.portal-card--request .field-hint.portal-hint-box a {
    color: var(--lse-primary-orange, #FF6B00);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.portal-card--request .field-hint.portal-hint-box a:hover {
    color: #e55a00;
}

@media (max-width: 480px) {
    .portal-card--request .field-hint.portal-hint-box {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}

/* Portal Hint Box in profile form (section-level guidance) */
.portal-card--submit .portal-hint-box {
    display: block;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #94a3b8;
    border-radius: 0 10px 10px 0;
    padding: 12px 14px;
    margin: 0 0 1.25rem;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #4b5563;
}

.portal-card--submit .portal-hint-box p {
    margin: 0 0 0.5rem;
}

.portal-card--submit .portal-hint-box ul {
    margin: 0;
    padding-left: 1.25rem;
    list-style-type: disc;
}

.portal-card--submit .portal-hint-box li {
    margin-bottom: 0.25rem;
}

.portal-card--submit .portal-hint-box li:last-child {
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .portal-card--submit .portal-hint-box {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}

/* =============================================================================
   B1: Live Validation Warnings (non-blocking amber state)
   ============================================================================= */

.portal-live-warning {
    display: block;
    padding: 10px 14px;
    margin: 0.75rem 0 0;
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.5;
    animation: portalWarningFadeIn 0.25s ease-out;
}

@keyframes portalWarningFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portal-live-warning--amber {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-left: 3px solid #f59e0b;
    color: #92400e;
}

.portal-live-warning--amber span {
    display: block;
}

/* Ensure warning appears below word counter */
.courses-overview-live-warning {
    margin-top: 0.5rem;
}

/* =============================================================================
   PP-01: Session Bar
   ============================================================================= */

.portal-session-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.portal-session-bar__role {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.portal-session-bar__role--super {
    background: #000032;
    color: #fff;
}

.portal-session-bar__logout {
    margin-left: auto;
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.portal-session-bar__logout:hover {
    background: #dc3545;
    color: #fff;
}

/* =============================================================================
   PP-02: Location Switcher
   ============================================================================= */

.portal-location-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #eef6fb;
    border: 1px solid #b8daff;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.portal-location-switcher label {
    font-weight: 600;
    white-space: nowrap;
}

.portal-location-switcher select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* =============================================================================
   PP-02A: Multi-School Terms Banner
   ============================================================================= */

.portal-terms-banner {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #f28c00;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 0 auto 1.25rem;
    max-width: 540px;
}

.portal-terms-banner__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
}

.portal-terms-banner__header svg {
    color: #f28c00;
    flex-shrink: 0;
}

.portal-terms-banner__header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.2;
}

.portal-terms-banner__count {
    margin-left: auto;
    font-size: 0.8rem;
    color: #6b7280;
    white-space: nowrap;
}

.portal-terms-banner__schools {
    margin-bottom: 1rem;
}

.portal-terms-banner__select-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
}

.portal-terms-banner__select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #f28c00;
    cursor: pointer;
}

.portal-terms-banner__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.portal-terms-banner__school {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s;
}

.portal-terms-banner__school:hover {
    background: #f9fafb;
}

.portal-terms-banner__school input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #f28c00;
    cursor: pointer;
}

.portal-terms-banner__school--accepted {
    opacity: 0.7;
    cursor: default;
}

.portal-terms-banner__school--accepted input[type="checkbox"] {
    accent-color: #10b981;
    cursor: default;
}

.portal-terms-banner__school-name {
    flex: 1;
}

.portal-terms-banner__school-date {
    font-size: 0.75rem;
    color: #10b981;
    white-space: nowrap;
}

.portal-terms-banner__footer {
    border-top: 1px solid #e5e7eb;
    padding-top: 0.75rem;
}

.portal-terms-banner__legal {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0 0 0.75rem;
    line-height: 1.4;
}

.portal-terms-banner__legal a {
    color: #f28c00;
    text-decoration: underline;
}

.portal-terms-banner__legal a:hover {
    color: #d97706;
}

.portal-terms-banner__submit {
    display: inline-block;
    background: #f28c00;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.portal-terms-banner__submit:hover:not(:disabled) {
    background: #d97706;
}

.portal-terms-banner__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.portal-terms-banner__message {
    margin-top: 0.5rem;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.portal-terms-banner__message--success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.portal-terms-banner__message--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* =============================================================================
   PP-02: Locations Grid
   ============================================================================= */

.portal-card--locations-view h2 {
    margin-bottom: 0.25rem;
}

.portal-locations-subtitle {
    color: #6b7280;
    font-size: 0.95rem;
    margin: 0 0 1.25rem;
}

/* Summary stats row */
.portal-locations-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal-locations-summary__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 2rem;
    background: #f8f9fb;
    border-radius: 10px;
    min-width: 120px;
}

.portal-locations-summary__number {
    font-size: 1.75rem;
    font-weight: 700;
    color: #000032;
    line-height: 1.2;
}

.portal-locations-summary__label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Grid */
.portal-locations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Card */
.portal-location-card {
    position: relative;
    padding: 1.25rem 1.25rem 1rem;
    background: #f8f9fb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-location-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 16px rgba(0, 0, 50, 0.06);
}

/* Parent (HQ) card accent */
.portal-location-card--parent {
    border-left: 3px solid #000032;
}

/* Card header: name + course count */
.portal-location-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.portal-location-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
}

.portal-location-card__course-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #000032;
    background: #eef1f6;
    padding: 3px 10px;
    border-radius: 9999px;
    white-space: nowrap;
}

/* HQ badge */
.portal-location-badge {
    display: inline-block;
    background: #000032;
    color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
}

/* Address */
.portal-location-card__address {
    color: #6b7280;
    font-size: 0.82rem;
    margin: 0 0 0.75rem;
    line-height: 1.45;
}

/* Actions row */
.portal-location-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
}

/* Buttons
   !important on color/background: theme.css neutral baseline sets
   button { color: #09374f; background: #ffffff } which can override
   class selectors depending on Autoptimize bundle order. */
.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 16px;
    border: 1px solid #d1d5db !important;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none !important;
    color: #374151 !important;
    background: #fff !important;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    transform: none !important;
}

.portal-btn:hover {
    background: #f9fafb !important;
    border-color: #9ca3af !important;
    color: #111827 !important;
    text-decoration: none !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Size modifiers */
.portal-btn--sm,
.portal-btn--small {
    padding: 4px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Outline modifier — transparent bg, coloured border */
.portal-btn.portal-btn--outline {
    background: transparent !important;
    border: 1px dashed #9ca3af !important;
    color: #6b7280 !important;
}
.portal-btn.portal-btn--outline:hover {
    border-color: #6b7280 !important;
    color: #374151 !important;
    background: #f9fafb !important;
}

/* CTA button — magenta default, orange on hover
   !important needed: parent theme library/css/style.css:2082 sets
   `a, a:visited { color: #444 !important }` which overrides link colours */
.portal-btn.portal-btn--cta,
.portal-btn.portal-btn--cta:visited {
    background: var(--lse-primary-magenta, #E6007E) !important;
    border-color: var(--lse-primary-magenta, #E6007E) !important;
    color: #fff !important;
}

.portal-btn.portal-btn--cta:hover,
.portal-btn.portal-btn--cta:visited:hover {
    background: var(--lse-secondary-orange, #EE7218) !important;
    border-color: var(--lse-secondary-orange, #EE7218) !important;
    color: #fff !important;
}

/* Responsive: stack on narrow screens */
@media (max-width: 640px) {
    .portal-locations-summary {
        gap: 0.75rem;
    }
    .portal-locations-summary__stat {
        padding: 0.75rem 1rem;
        flex: 1;
        min-width: 0;
    }
    .portal-locations-summary__number {
        font-size: 1.35rem;
    }
    .portal-locations-grid {
        grid-template-columns: 1fr;
    }
    .portal-location-card__actions {
        flex-direction: column;
    }
    .portal-location-card__actions .portal-btn--sm {
        text-align: center;
    }
}

/* =============================================================================
   PP-04: Lead Management — Redesigned
   ============================================================================= */

/* --- Filter Bar --- */
.portal-leads-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0 0 24px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid rgba(0, 0, 50, 0.08);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 50, 0.04);
}

.portal-leads-filter-bar .portal-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-leads-filter-bar label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--lse-structure-navy, #000032);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.portal-leads-filter-bar select,
.portal-leads-filter-bar .portal-leads-date-input {
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #000032;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}

.portal-leads-filter-bar select:focus,
.portal-leads-filter-bar .portal-leads-date-input:focus {
    outline: none;
    border-color: var(--lse-secondary-orange, #EE7218);
    box-shadow: 0 0 0 3px rgba(238, 114, 24, 0.12);
}

.portal-leads-filter-bar .portal-filter-separator {
    width: 1px;
    height: 28px;
    background: #e0e0e0;
    margin: 0 4px;
}

/* --- Summary Bar --- */
.portal-leads-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 2px;
}

.portal-leads-summary__count {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.portal-leads-summary__count strong {
    color: var(--lse-structure-navy, #000032);
}

/* --- Lead List --- */
.portal-leads-list {
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.portal-leads-loading,
.portal-leads-empty,
.portal-leads-error {
    text-align: center;
    padding: 48px 24px;
    color: #888;
    font-size: 0.95rem;
}

.portal-leads-loading::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid #e9ecef;
    border-top-color: var(--lse-secondary-orange, #EE7218);
    border-radius: 50%;
    animation: portal-spin 0.7s linear infinite;
}

@keyframes portal-spin {
    to { transform: rotate(360deg); }
}

.portal-leads-empty {
    background: #fff;
    border: 2px dashed #d0d5dd;
    border-radius: 10px;
}

.portal-leads-error {
    color: #dc3545;
    background: #fff5f5;
    border-radius: 10px;
    border: 1px solid #fecdd3;
}

/* --- Lead Card --- */
.portal-lead-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 50, 0.08);
    border-radius: 10px;
    padding: 0;
    margin-bottom: 0;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.portal-lead-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 50, 0.08);
    border-color: rgba(0, 0, 50, 0.14);
}

/* Status accent stripe on left */
.portal-lead-card[data-status="new"]            { border-left: 4px solid #3b82f6; }
.portal-lead-card[data-status="contacted"]      { border-left: 4px solid #f59e0b; }
.portal-lead-card[data-status="converted"]      { border-left: 4px solid #10b981; }
.portal-lead-card[data-status="not_interested"] { border-left: 4px solid #9ca3af; }
.portal-lead-card[data-status="no_response"]    { border-left: 4px solid #ef4444; }

/* Card header row */
.portal-lead-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px 12px;
}

.portal-lead-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

/* Name + badges row */
.portal-lead-card__name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.portal-lead-card__name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--lse-structure-navy, #000032);
    line-height: 1.3;
}

.portal-lead-card__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.portal-lead-card__badge--crosssell {
    background: rgba(106, 202, 243, 0.15);
    color: #0284c7;
}

.portal-lead-card__badge--variant {
    background: #f1f5f9;
    color: #64748b;
}

/* Contact details row */
.portal-lead-card__contact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    font-size: 0.85rem;
    color: #555;
}

.portal-lead-card__contact a {
    color: var(--lse-secondary-orange, #EE7218);
    text-decoration: none;
}

.portal-lead-card__contact a:hover {
    text-decoration: underline;
}

.portal-lead-card__contact-sep {
    color: #d0d5dd;
    font-size: 0.7rem;
}

/* Meta row (date, nationality) */
.portal-lead-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.portal-lead-card__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.portal-lead-card__meta-icon {
    font-size: 0.85rem;
    opacity: 0.6;
}

/* Status control */
.portal-lead-card__status {
    flex-shrink: 0;
}

.portal-lead-status-select {
    padding: 7px 28px 7px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #000032;
    background: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.portal-lead-status-select:focus {
    outline: none;
    border-color: var(--lse-secondary-orange, #EE7218);
    box-shadow: 0 0 0 3px rgba(238, 114, 24, 0.12);
}

/* Status-specific select colors */
.portal-lead-status-select[data-current="new"]            { border-color: #3b82f6; background-color: #eff6ff; color: #1d4ed8; }
.portal-lead-status-select[data-current="contacted"]      { border-color: #f59e0b; background-color: #fffbeb; color: #b45309; }
.portal-lead-status-select[data-current="converted"]      { border-color: #10b981; background-color: #ecfdf5; color: #047857; }
.portal-lead-status-select[data-current="not_interested"] { border-color: #9ca3af; background-color: #f9fafb; color: #4b5563; }
.portal-lead-status-select[data-current="no_response"]    { border-color: #ef4444; background-color: #fef2f2; color: #b91c1c; }

/* --- Card Body --- */
.portal-lead-card__body {
    padding: 0 20px 16px;
}

/* Course preferences pills */
.portal-lead-card__prefs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
}

.portal-lead-card__prefs .portal-pref-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(0, 0, 50, 0.04), rgba(106, 202, 243, 0.1));
    border: 1px solid rgba(106, 202, 243, 0.2);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #000032;
}

.portal-pref-pill__label {
    color: #888;
    font-weight: 400;
}

/* Message block */
.portal-lead-card__message {
    margin: 0 0 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #334155;
}

.portal-lead-card__message strong {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #94a3b8;
    margin-bottom: 4px;
    font-weight: 600;
}

/* --- Notes Section --- */
.portal-lead-card__notes {
    margin-top: 0;
    border-top: 1px solid #f1f5f9;
    padding-top: 12px;
}

.portal-lead-note {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #fffdf5;
    border-left: 3px solid #fbbf24;
    border-radius: 0 6px 6px 0;
    font-size: 0.82rem;
    line-height: 1.5;
}

.portal-lead-note__text {
    color: #334155;
}

.portal-lead-note__meta {
    display: block;
    color: #94a3b8;
    font-size: 0.72rem;
    margin-top: 3px;
}

.portal-lead-card__add-note {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 10px;
}

.portal-lead-note-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.82rem;
    resize: vertical;
    min-height: 36px;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    color: #334155;
}

.portal-lead-note-input:focus {
    outline: none;
    border-color: var(--lse-secondary-orange, #EE7218);
    box-shadow: 0 0 0 3px rgba(238, 114, 24, 0.1);
}

.portal-lead-add-note-btn {
    padding: 8px 16px !important;
    background: var(--lse-structure-navy, #000032) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.portal-lead-add-note-btn:hover {
    background: #1a1a4e !important;
}

/* --- Pagination --- */
.portal-leads-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding: 16px;
    background: #fff;
    border: 1px solid rgba(0, 0, 50, 0.08);
    border-radius: 10px;
}

.portal-leads-pagination button {
    padding: 8px 18px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--lse-structure-navy, #000032);
    transition: background 0.15s, border-color 0.15s;
}

.portal-leads-pagination button:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #94a3b8;
}

.portal-leads-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.portal-leads-pagination__info {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

/* --- Leads View Header --- */
.portal-card--leads-view > h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--lse-structure-navy, #000032);
    margin: 0 0 4px;
}

.portal-card--leads-view > p {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0 0 20px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .portal-leads-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 16px;
    }

    .portal-leads-filter-bar .portal-filter-group {
        width: 100%;
    }

    .portal-leads-filter-bar select,
    .portal-leads-filter-bar .portal-leads-date-input {
        flex: 1;
        width: 100%;
    }

    .portal-leads-filter-bar .portal-filter-separator {
        display: none;
    }

    .portal-lead-card__header {
        flex-direction: column;
        gap: 10px;
        padding: 14px 16px 10px;
    }

    .portal-lead-card__status {
        align-self: flex-start;
    }

    .portal-lead-card__body {
        padding: 0 16px 14px;
    }

    .portal-lead-card__contact {
        flex-direction: column;
        gap: 2px;
    }

    .portal-lead-card__contact-sep {
        display: none;
    }
}

/* =============================================================================
   Analytics Tabs (Lead Stats / Website Traffic)
   ============================================================================= */

.portal-analytics-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 24px;
}

.portal-analytics-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.portal-analytics-tab:hover {
    color: #374151;
}

.portal-analytics-tab--active {
    color: #000032;
    border-bottom-color: #F57C20;
}

.portal-analytics-panel__intro {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.portal-analytics-panel[hidden] {
    display: none;
}

/* Traffic panel reuses existing .portal-analytics__stats, .portal-stat,
   .portal-breakdown-table, .portal-analytics__privacy, .portal-analytics__updated */

/* Choice card icons — background circles + hover inversion */
.portal-choice__icon--leads {
    background: #fef3e2;
    color: #e67e22;
}

.portal-choice__option:hover .portal-choice__icon--leads {
    background: #e67e22;
    color: #fff;
}

.portal-choice__icon--locations {
    background: #e8e8f0;
    color: #000032;
}

.portal-choice__option:hover .portal-choice__icon--locations {
    background: #000032;
    color: #fff;
}

.portal-choice__icon--courses {
    background: #d1fae5;
    color: #059669;
}

.portal-choice__option:hover .portal-choice__icon--courses {
    background: #047857;
    color: #fff;
}

/* =============================================================================
   Partner Onboarding Page
   ============================================================================= */

.portal-card--onboarding {
    max-width: 720px;
}

/* Profile Summary */
.onboarding-profile-summary {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.onboarding-profile-summary__logo {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

.onboarding-profile-summary__logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.onboarding-profile-summary__details {
    flex: 1;
    min-width: 0;
}

.onboarding-profile-summary__details .portal-form__field {
    margin-bottom: 0.75rem;
}

.onboarding-profile-summary__details .portal-form__field label {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.onboarding-profile-summary__details .portal-form__field input[readonly] {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Admin Email Editor */
.admin-email-row {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.admin-email-row:last-child {
    border-bottom: none;
}

.admin-email-row__fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.admin-email-row__fields .portal-form__field {
    margin-bottom: 0;
}

.admin-email-row__fields .portal-form__field label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.admin-email-row__fields .portal-form__field input,
.admin-email-row__fields .portal-form__field select {
    padding: 10px 12px;
    font-size: 0.9rem;
}

.admin-email-row__fields select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-family: inherit;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.admin-email-row__fields select:focus {
    outline: none;
    border-color: #e6007e;
    box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.1);
}

.admin-email-row__remove {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.2s ease;
    align-self: end;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-email-row__remove:hover:not(:disabled) {
    color: #dc3545;
    border-color: #dc3545;
    background: #fef2f2;
}

.admin-email-row__remove:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Admin row permissions (onboarding, super_admin view only) */
.admin-email-row__permissions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    padding: 0.5rem 0 0;
}
.admin-email-row__perm-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #4b5563;
    cursor: pointer;
    white-space: nowrap;
}
.admin-email-row__perm-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #7c3aed;
}

/* Disabled role select */
.admin-email-row__fields select:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    opacity: 0.8;
}

/* Add Admin Button */
.portal-btn--secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--lse-dark-blue, #000032) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    box-shadow: none !important;
    text-transform: none !important;
}

.portal-btn--secondary:hover:not(:disabled) {
    border-color: #e6007e !important;
    color: #e6007e !important;
    background: #fef2f8 !important;
}

.portal-btn--secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Terms accepted confirmation (reuse from portal) */
.portal-card--onboarding .portal-terms__accepted {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #059669;
    font-size: 0.95rem;
}

.portal-card--onboarding .portal-terms__check-icon {
    color: #059669;
    flex-shrink: 0;
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
    .onboarding-profile-summary {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .admin-email-row__fields {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .admin-email-row__remove {
        align-self: flex-end;
    }

    .portal-card--onboarding {
        padding: 24px 20px;
    }
}

/* ==========================================================================
   Promotions Section
   ========================================================================== */

.portal-card--promotions-view h2 {
    margin-bottom: 8px;
}

.portal-promos-list {
    margin: 24px 0;
}

.portal-promos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 24px;
}
.portal-promos-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.portal-promos-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.portal-promos-table tr:hover td {
    background: #fafafa;
}

.portal-promo-status--active { color: #198754; font-weight: 600; }
.portal-promo-status--upcoming { color: #0d6efd; }
.portal-promo-status--expired { color: #dc3545; }
.portal-promo-status--draft { color: #999; font-style: italic; }

.portal-promos-create {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
    margin-top: 24px;
}
.portal-promos-create h3 {
    margin: 0 0 16px;
    font-size: 18px;
}

.portal-promos-form .portal-form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.portal-promos-form .portal-form-field {
    flex: 1;
    min-width: 200px;
}
.portal-promos-form .portal-form-field--half {
    flex: 1 1 45%;
}
.portal-promos-form .portal-form-field--quarter {
    flex: 0 0 120px;
    min-width: 120px;
}
.portal-promos-form label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}
.portal-promos-form label .required {
    color: #E6007E;
}
.portal-promos-form input[type="text"],
.portal-promos-form input[type="number"],
.portal-promos-form input[type="date"],
.portal-promos-form select,
.portal-promos-form textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
.portal-promos-form textarea {
    resize: vertical;
}
.portal-promos-form .portal-field-hint {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.portal-promo-courses-checkboxes {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px 12px;
    background: #fff;
}
.portal-promo-course-option {
    display: block;
    padding: 4px 0;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
}
.portal-promo-course-option input {
    margin-right: 8px;
}

.portal-form-actions {
    margin-top: 16px;
}

.portal-form-messages {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 14px;
}
.portal-form-messages--success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.portal-form-messages--error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Danger button — red bg, white text
   !important needed: theme.css neutral baseline sets button { color: #09374f }
   and Autoptimize bundle order can vary. Matches CTA button pattern. */
.portal-btn.portal-btn--danger,
.portal-btn.portal-btn--danger:visited {
    background: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
}
.portal-btn.portal-btn--danger:hover,
.portal-btn.portal-btn--danger:visited:hover {
    background: #c82333 !important;
    border-color: #c82333 !important;
    color: #fff !important;
}

.portal-choice__icon--promotions {
    background: #fce4f0;
    color: #E6007E;
}

.portal-choice__option:hover .portal-choice__icon--promotions {
    background: #E6007E;
    color: #fff;
}

/* =============================================================================
   Team Management (PP-04: Role & Permissions)
   ============================================================================= */

/* Choice card icon */
.portal-choice__icon--team {
    background: #ede9fe;
    color: #7c3aed;
}
.portal-choice__option:hover .portal-choice__icon--team {
    background: #7c3aed;
    color: #fff;
}

/* Team table */
.portal-team-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}
.portal-team-table thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.portal-team-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    color: #4b5563;
    vertical-align: middle;
}
.portal-team-table tbody tr:hover td {
    background: #fafafa;
}
.portal-team-row--self td {
    background: #fef3c7 !important;
}

/* Role badges */
.portal-team-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.portal-team-role-badge--super_admin {
    background: #dbeafe;
    color: #1e40af;
}
.portal-team-role-badge--location_admin {
    background: #f3f4f6;
    color: #4b5563;
}

/* Permission badges */
.portal-team-perms-cell {
    max-width: 280px;
}
.portal-team-perm-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    margin: 1px 2px;
    white-space: nowrap;
}
.portal-team-perm-badge--on {
    background: #dcfce7;
    color: #166534;
}
.portal-team-perm-badge--off {
    background: #fee2e2;
    color: #991b1b;
    text-decoration: line-through;
}
.portal-team-perm-badge--full {
    background: #dbeafe;
    color: #1e40af;
}

/* Actions cell */
.portal-team-actions-cell {
    white-space: nowrap;
    text-align: right;
}

/* Team form */
.portal-team-form-wrapper {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e5e7eb;
}
.portal-team-form-wrapper h3 {
    font-size: 1.2rem;
    color: #1f2937;
    margin-bottom: 1rem;
}
.portal-team-form__actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1rem;
}

/* Permission toggles (checkboxes in form) */
.portal-team-permissions {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-top: 0.75rem;
    background: #f9fafb;
}
.portal-team-permissions legend {
    font-weight: 600;
    font-size: 0.95rem;
    color: #374151;
    padding: 0 0.25rem;
}
.portal-team-permissions__hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0.25rem 0 0.75rem;
}
.portal-team-permissions__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}
.portal-team-perm-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    transition: background 0.15s;
}
.portal-team-perm-toggle:hover {
    background: #e5e7eb;
}
.portal-team-perm-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #7c3aed;
}

/* Email notification preferences (visible for all roles) */
.portal-team-notifications {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1rem 0 0;
    background: #f9fafb;
}
.portal-team-notifications legend {
    font-weight: 600;
    font-size: 0.95rem;
    color: #374151;
    padding: 0 0.25rem;
}
.portal-team-notifications__hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0.25rem 0 0.75rem;
}
.portal-team-notifications__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

/* Apply-to-all option */
.portal-team-apply-all {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: #eff6ff;
    border-radius: 8px;
    border: 1px solid #bfdbfe;
}

/* Responsive */
@media (max-width: 768px) {
    .portal-team-table thead {
        display: none;
    }
    .portal-team-table,
    .portal-team-table tbody,
    .portal-team-table tr,
    .portal-team-table td {
        display: block;
    }
    .portal-team-table tr {
        padding: 0.75rem 0;
        border-bottom: 1px solid #e5e7eb;
    }
    .portal-team-table td {
        padding: 0.25rem 0;
        border: none;
    }
    .portal-team-table td:before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6b7280;
        text-transform: uppercase;
        display: block;
        margin-bottom: 0.15rem;
    }
    .portal-team-perms-cell {
        max-width: 100%;
    }
    .portal-team-actions-cell {
        text-align: left;
        padding-top: 0.5rem;
    }
    .portal-team-permissions__grid,
    .portal-team-notifications__grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   Video URL fields — Partner Portal (§100)
   ============================================================================ */
.video-urls-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.video-url-row__input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.video-url-row__input-group .video-url-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.video-url-row__input-group .video-url-input:focus {
    border-color: #f97316;
    outline: none;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

.video-url-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #9ca3af;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
}

.video-url-remove:hover {
    color: #ef4444;
    border-color: #ef4444;
}

.video-url-preview {
    margin-top: 0.35rem;
}

.video-url-thumb {
    max-width: 160px;
    border-radius: 4px;
    display: block;
}

.video-url-error {
    color: #ef4444;
    font-size: 0.82rem;
}

.video-url-vimeo-label {
    color: #6b7280;
    font-size: 0.82rem;
}

#add-video-btn {
    margin-top: 0.5rem;
}
