/* Admin Dashboard Styles */

/* The admin shell is deliberately scoped so portal pages keep their own theme. */
body.admin-body {
    --admin-accent: #6546a8;
    --admin-accent-dark: #4d3285;
    --admin-surface: #ffffff;
    --admin-border: #e2dfeb;
    --admin-text: #272334;
    --admin-muted: #706b7c;
    background: #f6f5f9;
    color: var(--admin-text);
}

body.admin-body .container {
    max-width: 1440px;
}

body.admin-body :focus-visible {
    outline: 3px solid #b7a3e5;
    outline-offset: 2px;
}

body.admin-body .dashboard-header,
body.admin-body .dashboard-content,
body.admin-body .detail-card,
body.admin-body .stat-card {
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(44, 34, 73, 0.05);
}

body.admin-body .btn-primary,
body.admin-body .btn-small {
    min-height: 40px;
}

body.admin-body .btn-primary {
    background: var(--admin-accent);
    border: 1px solid var(--admin-accent);
    border-radius: 8px;
    box-shadow: none;
    color: #fff;
    font-weight: 700;
}

body.admin-body .btn-primary:hover {
    background: var(--admin-accent-dark);
}

body.admin-body .btn-small {
    align-items: center;
    background: #f1edfb;
    border: 1px solid #d8ceed;
    border-radius: 8px;
    color: var(--admin-accent-dark);
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    line-height: 1.2;
    padding: 8px 12px;
    text-decoration: none;
}

body.admin-body .btn-small:hover {
    background: #e4dcf7;
    color: #3d266d;
}

body.admin-body .btn-danger {
    background: #fce9eb;
    border-color: #f2c6ca;
    color: #9d2530;
}

body.admin-body input,
body.admin-body select,
body.admin-body textarea {
    border: 1px solid #cac3d7;
    border-radius: 8px;
    min-height: 40px;
}

body.admin-body textarea { min-height: 96px; }
body.admin-body .stat-value { color: var(--admin-accent); }
body.admin-body .nav-brand { color: var(--admin-accent); }
body.admin-body .data-table th { color: #514b5c; }
body.admin-body .data-table td { border-color: #ece9f1; }
body.admin-body .data-table tr:hover { background: #faf9fd; }

body.admin-body .sidebar-link.is-active {
    background: #eee9fb;
    color: var(--admin-accent-dark);
    font-weight: 700;
    border-right: 3px solid var(--admin-accent);
}

body.admin-body .badge-info { background: #e6eefb; color: #294b86; }
body.admin-body .badge-success { background: #e1f3e8; color: #17633b; }
body.admin-body .badge-warning { background: #fff1cf; color: #805600; }
body.admin-body .badge-danger { background: #fce4e6; color: #9d2530; }
body.admin-body .badge-muted { background: #e9e7ed; color: #5e5968; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.filter-bar label { display: grid; gap: 4px; color: #4d4858; font-size: 14px; }
.filter-bar select { min-height: 40px; }
.filter-bar .btn-small { background: var(--admin-accent); border-color: var(--admin-accent); color: #fff; }
.filter-bar .btn-small:hover { background: var(--admin-accent-dark); color: #fff; }
.pagination { display: flex; gap: 16px; margin-top: 16px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; color: var(--admin-muted); font-size: 14px; }
.breadcrumbs a { color: var(--admin-accent-dark); }
.cohort-create-panel { margin-bottom: 20px; }
.cohort-create-panel summary { cursor: pointer; color: var(--admin-accent-dark); font-weight: 700; }
.cohort-create-panel[open] summary { margin-bottom: 20px; }
.report-regenerate { margin-bottom: 24px; }
.status-note { color: var(--admin-muted); font-size: 13px; }

@media (min-width: 1200px) {
    body.admin-body .sidebar {
        transform: none;
        width: 236px;
        box-shadow: none;
        border-right: 1px solid var(--admin-border);
    }

    body.admin-body .sidebar-close,
    body.admin-body .nav-toggle {
        display: none;
    }

    body.admin-body .nav-bar {
        display: none;
    }

    body.admin-body .container {
        margin-left: 236px;
        width: calc(100% - 236px);
        padding: 28px 32px;
    }
}

@media (max-width: 1199px) {
    body.admin-body .nav-toggle { display: flex; }
    body.admin-body .nav-menu { display: none; }
    body.admin-body .nav-user { margin-left: auto; }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
}

.login-box .subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #4a90d9;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: #4a90d9;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: #3a7bc8;
}

.login-btn:active {
    background-color: #2d6bb5;
}

.error-message {
    background-color: #fee;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    text-align: center;
}

.report-warning {
    text-align: left;
}

.report-warning strong {
    display: block;
    text-align: center;
}

.report-warning ul {
    width: fit-content;
    max-width: 100%;
    margin: 8px auto 0;
    padding-left: 22px;
}

/* Dashboard Styles (for future use) */
.dashboard-header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dashboard-header h1 {
    font-size: 24px;
    color: #333;
}

.dashboard-header .subtitle {
    color: #666;
    font-size: 14px;
    margin-top: 4px;
}

.dashboard-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dashboard-content h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
}

/* Navigation Bar */
.nav-bar {
    background: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
}

.nav-brand {
    font-size: 18px;
    font-weight: 600;
    color: #4a90d9;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    gap: 4px;
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: #333;
    border-radius: 2px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    transition: opacity 0.3s;
}

.sidebar-overlay-active {
    display: block;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: white;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
}

.sidebar-open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0 4px;
}

.sidebar-close:hover {
    color: #333;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-link {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: #f0f7ff;
    color: #4a90d9;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
}

.sidebar-user {
    font-weight: 500;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: #4a90d9;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

.nav-logout {
    color: #dc3545;
    text-decoration: none;
}

.nav-logout:hover {
    text-decoration: underline;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

body.admin-body .attention-section {
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 600;
    color: #4a90d9;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.adolescent-uploader {
    margin-bottom: 20px;
}

body.admin-body .user-test-history {
    margin-bottom: 20px;
}

body.admin-body .user-report-action {
    margin-bottom: 16px;
}

body.admin-body .user-report-status {
    min-width: 190px;
}

body.admin-body .report-status-age,
body.admin-body .report-status-error {
    display: block;
    font-size: 11px;
    margin-top: 5px;
}

body.admin-body .report-status-age {
    color: #777;
}

body.admin-body .report-status-error {
    color: #a12a36;
    max-width: 360px;
}

body.admin-body .report-status-error[hidden],
body.admin-body .report-generation-error[hidden] {
    display: none;
}

body.admin-body .report-source-profile + .report-source-profile {
    margin-top: 20px;
}

body.admin-body .report-source-heading {
    margin-bottom: 18px;
}

body.admin-body .report-source-heading h2 {
    margin-bottom: 6px;
}

body.admin-body .report-source-heading p {
    color: #666;
}

body.admin-body .report-source-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

body.admin-body .report-source-card {
    border: 1px solid #e4e4e4;
    box-shadow: none;
    min-width: 0;
    overflow: visible;
}

body.admin-body .report-source-card legend {
    font-weight: 700;
    padding: 0 6px;
}

body.admin-body .report-source-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

body.admin-body .report-source-card select {
    width: 100%;
}

.adolescent-uploader-heading,
.report-actions,
.report-back-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.adolescent-uploader-heading {
    justify-content: space-between;
    margin-bottom: 18px;
}

.adolescent-uploader-heading h2 {
    margin-bottom: 4px;
}

.adolescent-stage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.adolescent-stage-form {
    padding: 16px;
    border: 1px solid #e4e4e4;
    border-radius: 8px;
    background: #fafafa;
}

.adolescent-stage-form p {
    margin-bottom: 10px;
    color: #666;
    font-size: 14px;
}

.adolescent-stage-form textarea {
    width: 100%;
    min-height: 108px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    font: inherit;
}

.adolescent-stage-form textarea:focus {
    outline: 2px solid #cce5ff;
    border-color: #4a90d9;
}

.adolescent-stage-form textarea:disabled {
    background: #eee;
}

.adolescent-stage-form button:disabled {
    opacity: .6;
    cursor: wait;
}

.adolescent-inline-preview {
    margin-top: 16px;
}

.inline-preview-panel,
.inline-feedback {
    padding: 16px;
    border-radius: 8px;
}

.inline-preview-panel {
    border: 1px solid #b8d8f8;
    background: #f4f9ff;
}

.inline-preview-card {
    margin: 12px 0;
    padding: 12px;
    border-radius: 6px;
    background: white;
}

.replacement-confirmation {
    display: block;
    margin: 12px 0;
}

.inline-feedback-error {
    color: #721c24;
    border: 1px solid #f5c6cb;
    background: #fee;
}

.inline-feedback-success {
    color: #155724;
    border: 1px solid #c3e6cb;
    background: #d4edda;
}

.adolescent-slot-status {
    margin-top: 18px;
}

.report-actions form {
    margin: 0;
}

.detail-card h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
}

.detail-card h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 12px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    font-weight: 600;
    color: #333;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    font-size: 14px;
    color: #666;
}

.data-table tbody tr:hover {
    background-color: #f9f9f9;
}

.info-table {
    width: 100%;
}

.info-table td {
    padding: 8px 0;
    font-size: 14px;
}

.info-table td:first-child {
    color: #666;
    width: 40%;
}

.info-table td:last-child {
    color: #333;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.badge-secondary {
    background-color: #e9ecef;
    color: #6c757d;
}

.badge-primary {
    background-color: #cce5ff;
    color: #004085;
}

.badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Buttons */
.btn-small {
    display: inline-block;
    padding: 6px 12px;
    background-color: #4a90d9;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-small:hover {
    background-color: #3a7bc8;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-primary {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4a90d9;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #3a7bc8;
}

/* Action Links */
.action-links {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.action-link {
    display: inline-block;
    padding: 12px 20px;
    background-color: #f8f9fa;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid #ddd;
    transition: all 0.2s;
}

.action-link:hover {
    background-color: #4a90d9;
    color: white;
    border-color: #4a90d9;
}

/* Forms */
.form-vertical {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-vertical .form-group {
    margin-bottom: 0;
}

.form-vertical textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.form-vertical textarea:focus {
    outline: none;
    border-color: #4a90d9;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.inline-form select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 200px;
}

.form-vertical select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.portal-inline-form {
    margin: 0;
}

.nav-logout-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

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

.portal-detail-grid {
    align-items: start;
}

.portal-message-card {
    max-width: 720px;
    margin: 40px auto 0;
}

.portal-nav-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.portal-nav-menu a {
    color: #D8488D;
    text-decoration: none;
    font-size: 14px;
}

.portal-nav-menu a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .portal-nav-menu {
        display: flex;
    }
}

/* Messages */
.empty-message {
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.success-message {
    color: #155724;
    background-color: #d4edda;
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 16px;
}

.back-link {
    margin-top: 20px;
}

.back-link a {
    color: #4a90d9;
    text-decoration: none;
}

.back-link a:hover {
    text-decoration: underline;
}

/* Dashboard Section */
.dashboard-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
}

.dashboard-section h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
}

.report-text-block {
    white-space: pre-line;
    color: #333;
    line-height: 1.5;
    background: #f8fafc;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0 16px;
}

/* Table scroll wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .login-box {
        padding: 30px 20px;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        display: none;
    }

    .container {
        padding: 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .filters-section {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .filter-group select {
        flex: 1;
        min-width: 0;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }

    .action-links {
        flex-direction: column;
    }

    .action-link {
        text-align: center;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form select {
        min-width: 0;
        width: 100%;
    }

    .pagination {
        flex-direction: column;
        gap: 10px;
    }

    .message {
        max-width: 95%;
    }

    .dashboard-header h1 {
        font-size: 20px;
    }

    .dashboard-section,
    .dashboard-content,
    .conversation-container,
    .funnel-section,
    .detail-card {
        padding: 14px;
    }

    .funnel-stage {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 12px;
    }

    .info-table td:first-child {
        width: 45%;
    }

    .btn-small {
        padding: 5px 10px;
        font-size: 12px;
    }

    .btn-primary {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* Conversation History */
.conversation-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin-bottom: 20px;
}

.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    max-width: 80%;
}

.message-user {
    background-color: #e3f2fd;
    margin-left: auto;
    text-align: right;
}

.message-assistant {
    background-color: #f5f5f5;
    margin-right: auto;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
}

.message-role {
    font-weight: 600;
    color: #666;
}

.message-time {
    color: #999;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-wrap: break-word;
    white-space: pre-wrap;
}

body.admin-body .message-text-markdown {
    overflow-wrap: anywhere;
    white-space: normal;
}

body.admin-body .message-text-markdown p,
body.admin-body .message-text-markdown ul,
body.admin-body .message-text-markdown ol,
body.admin-body .message-text-markdown pre,
body.admin-body .message-text-markdown table {
    margin: 0 0 10px;
}

body.admin-body .message-text-markdown p:last-child,
body.admin-body .message-text-markdown ul:last-child,
body.admin-body .message-text-markdown ol:last-child,
body.admin-body .message-text-markdown pre:last-child,
body.admin-body .message-text-markdown table:last-child {
    margin-bottom: 0;
}

body.admin-body .message-text-markdown ul,
body.admin-body .message-text-markdown ol {
    padding-left: 20px;
}

body.admin-body .message-text-markdown h1,
body.admin-body .message-text-markdown h2,
body.admin-body .message-text-markdown h3,
body.admin-body .message-text-markdown h4,
body.admin-body .message-text-markdown h5,
body.admin-body .message-text-markdown h6 {
    font-size: 1rem;
    margin: 0 0 8px;
}

body.admin-body .message-text-markdown hr {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 12px 0;
}

body.admin-body .message-text-markdown pre,
body.admin-body .message-text-markdown code {
    background: #eee;
    border: 1px solid #ddd;
    border-radius: 6px;
}

body.admin-body .message-text-markdown pre {
    overflow-x: auto;
    padding: 10px;
}

body.admin-body .message-text-markdown pre code {
    background: transparent;
    border: 0;
    padding: 0;
}

body.admin-body .message-text-markdown code {
    font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
    font-size: .92em;
    padding: 1px 5px;
}

body.admin-body .message-text-markdown table {
    border-collapse: collapse;
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

body.admin-body .message-text-markdown th,
body.admin-body .message-text-markdown td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: left;
}

body.admin-body .report-generation-error p {
    margin-top: 6px;
}

.message-meta {
    margin-top: 8px;
    font-size: 11px;
    color: #999;
}

.message-meta span {
    margin-right: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.pagination-link {
    display: inline-block;
    padding: 8px 16px;
    background-color: #4a90d9;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.pagination-link:hover {
    background-color: #3a7bc8;
}

.pagination-info {
    font-size: 14px;
    color: #666;
}

/* Filter Section */
.filters-section {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: #555;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: #4a90d9;
}

/* Funnel Section */
.funnel-section {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.funnel-section h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
}

.funnel-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.funnel-stage {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.funnel-stage:last-child {
    border-bottom: none;
}

.stage-name {
    font-size: 14px;
    color: #555;
}

.stage-count {
    font-size: 18px;
    font-weight: 600;
    color: #4a90d9;
}

/* Participant portal report-style overrides */
body.portal-body {
    --portal-bg: #FFF9FC;
    --portal-surface: #FFFFFF;
    --portal-surface-soft: #FFF7FB;
    --portal-surface-warm: #FFF8E8;
    --portal-highlight: #FFF2BB;
    --portal-highlight-border: #E9C85F;
    --portal-primary: #D8488D;
    --portal-primary-hover: #A51F62;
    --portal-heading: #6F2A73;
    --portal-heading-soft: #7B2E79;
    --portal-text: #3A3340;
    --portal-muted: #6F5871;
    --portal-muted-soft: #7B6A80;
    --portal-border: #E8CFE0;
    --portal-border-strong: #E5A7C5;
    --portal-shadow-soft: 0 4px 16px rgba(58, 51, 64, 0.06);
    --portal-shadow-raised: 0 12px 32px rgba(111, 42, 115, 0.10);
    --portal-focus-ring: 0 0 0 4px rgba(216, 72, 141, 0.16);

    background: var(--portal-bg);
    color: var(--portal-text);
}

body.portal-body {
    min-height: 100%;
}

body.portal-body.portal-chat-page {
    height: 100dvh;
    overflow: hidden;
}

body.portal-body a {
    color: var(--portal-primary);
}

body.portal-body a:hover {
    color: var(--portal-primary-hover);
}

body.portal-body h1,
body.portal-body h2,
body.portal-body h3 {
    color: var(--portal-heading);
}

body.portal-body p {
    line-height: 1.6;
}

body.portal-body .container {
    max-width: 1120px;
    padding: 28px 20px 48px;
}

body.portal-body.portal-chat-page .container {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--portal-nav-height, 73px));
    min-height: 0;
    overflow: hidden;
    padding-bottom: 20px;
}

body.portal-body .nav-bar {
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--portal-border);
    box-shadow: var(--portal-shadow-soft);
    gap: 18px;
    flex-wrap: nowrap;
    min-height: 56px;
    padding: 8px 16px;
}

body.portal-body.portal-chat-page .nav-bar {
    flex: 0 0 auto;
}

body.portal-body .nav-brand {
    color: var(--portal-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

body.portal-body .nav-menu,
body.portal-body .portal-nav-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
}

body.portal-body .portal-nav-menu a,
body.portal-body .portal-nav-link {
    color: var(--portal-muted);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    padding: 7px 10px;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

body.portal-body .portal-nav-link:hover,
body.portal-body .portal-nav-link.is-active {
    background: var(--portal-surface-soft);
    color: var(--portal-primary);
    text-decoration: none;
}

body.portal-body .portal-nav-link:focus-visible,
body.portal-body .nav-logout-button:focus-visible,
body.portal-body .btn-primary:focus-visible,
body.portal-body .btn-small:focus-visible,
body.portal-body .back-link a:focus-visible {
    outline: none;
    box-shadow: var(--portal-focus-ring);
}

body.portal-body .nav-user {
    color: var(--portal-muted);
    flex: 0 0 auto;
    gap: 0;
    position: relative;
}

body.portal-body .nav-user span,
body.portal-body .portal-user-label {
    overflow-wrap: anywhere;
}

body.portal-body .portal-user-menu > summary {
    list-style: none;
}

body.portal-body .portal-user-menu > summary::-webkit-details-marker {
    display: none;
}

body.portal-body .portal-user-menu-button {
    align-items: center;
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    font-size: 18px;
    height: 36px;
    justify-content: center;
    padding: 0;
    width: 36px;
}

body.portal-body .portal-user-menu-button:focus-visible {
    outline: none;
    box-shadow: var(--portal-focus-ring);
}

body.portal-body .portal-user-dropdown {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    box-shadow: var(--portal-shadow-raised);
    display: grid;
    gap: 10px;
    min-width: min(260px, calc(100vw - 24px));
    padding: 12px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 20;
}

body.portal-body .portal-user-label {
    color: var(--portal-muted);
    font-size: 13px;
    line-height: 1.35;
}

body.portal-body .nav-logout-button {
    color: var(--portal-primary-hover);
    border: 1px solid var(--portal-border);
    border-radius: 999px;
    background: var(--portal-surface);
    padding: 7px 12px;
}

body.portal-body .nav-logout-button:hover {
    background: var(--portal-surface-soft);
    text-decoration: none;
}

body.portal-body .dashboard-header {
    position: relative;
    background: linear-gradient(135deg, var(--portal-surface-soft), var(--portal-surface));
    border: 1px solid var(--portal-border-strong);
    border-left: 6px solid var(--portal-primary);
    border-radius: 24px;
    box-shadow: var(--portal-shadow-raised);
    margin-bottom: 24px;
    padding: 28px;
}

body.portal-body .dashboard-header h1 {
    font-size: 30px;
    line-height: 1.15;
    margin-bottom: 8px;
}

body.portal-body .dashboard-header .subtitle,
body.portal-body .subtitle {
    color: var(--portal-muted);
    font-size: 15px;
}

body.portal-body .dashboard-content,
body.portal-body .dashboard-section,
body.portal-body .detail-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 20px;
    box-shadow: var(--portal-shadow-soft);
    color: var(--portal-text);
    padding: 24px;
}

body.portal-body .dashboard-section {
    margin-top: 22px;
}

body.portal-body .dashboard-section h2,
body.portal-body .dashboard-content h2,
body.portal-body .detail-card h2 {
    color: var(--portal-heading);
    font-size: 20px;
    margin-bottom: 16px;
}

body.portal-body .detail-card h3 {
    color: var(--portal-heading-soft);
    font-size: 17px;
}

body.portal-body .portal-login-card {
    background: linear-gradient(135deg, var(--portal-surface-soft), var(--portal-surface));
}

body.portal-body .portal-help-card,
body.portal-body .portal-message-card {
    background: var(--portal-surface-warm);
}

body.portal-body .portal-field-error {
    color: #a12a36;
    display: block;
    font-size: 13px;
    min-height: 20px;
    padding-top: 4px;
}

body.portal-body .portal-consent-control {
    align-items: flex-start;
    background: var(--portal-surface-warm);
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    display: flex;
    gap: 12px;
    padding: 16px;
}

body.portal-body .portal-consent-control input[type="checkbox"] {
    flex: 0 0 auto;
    height: 20px;
    margin-top: 2px;
    width: 20px;
}

body.portal-body .portal-registration-summary {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

body.portal-body .portal-registration-summary div {
    border-bottom: 1px solid var(--portal-border);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(100px, 0.35fr) 1fr;
    padding-bottom: 10px;
}

body.portal-body .portal-registration-summary dt,
body.portal-body .portal-legal-kicker {
    color: var(--portal-muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

body.portal-body .portal-registration-summary dd {
    margin: 0;
    overflow-wrap: anywhere;
}

body.portal-body .portal-legal-page {
    margin: 0 auto;
    max-width: 820px;
}

body.portal-body .portal-legal-content {
    line-height: 1.65;
    max-height: 520px;
    overflow: auto;
    padding-right: 8px;
}

body.portal-body .portal-legal-page .portal-legal-content {
    max-height: none;
    overflow: visible;
}

@media (max-width: 700px) {
    body.portal-body .portal-registration-summary div {
        gap: 4px;
        grid-template-columns: 1fr;
    }

    body.portal-body .portal-legal-content {
        max-height: none;
    }
}

body.portal-body .portal-message-card {
    border-left: 6px solid var(--portal-primary);
}

body.portal-body .info-table {
    border-collapse: collapse;
}

body.portal-body .info-table td {
    border-bottom: 1px solid #F3DFEC;
    color: var(--portal-text);
    padding: 10px 0;
}

body.portal-body .info-table tr:last-child td {
    border-bottom: none;
}

body.portal-body .info-table td:first-child {
    color: var(--portal-muted);
    font-weight: 600;
}

body.portal-body .form-group label {
    color: var(--portal-heading);
    font-weight: 700;
}

body.portal-body .form-group input,
body.portal-body .form-vertical textarea,
body.portal-body .form-vertical select,
body.portal-body .inline-form select {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    color: var(--portal-text);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

body.portal-body .form-group input:focus,
body.portal-body .form-vertical textarea:focus,
body.portal-body .form-vertical select:focus,
body.portal-body .inline-form select:focus {
    background: var(--portal-surface);
    border-color: var(--portal-primary);
    box-shadow: var(--portal-focus-ring);
    outline: none;
}

body.portal-body .btn-primary,
body.portal-body .login-btn {
    background: var(--portal-primary);
    border: 1px solid var(--portal-primary);
    border-radius: 999px;
    color: #FFFFFF;
    font-weight: 700;
    padding: 11px 20px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

body.portal-body .btn-primary:hover,
body.portal-body .login-btn:hover {
    background: var(--portal-primary-hover);
    border-color: var(--portal-primary-hover);
    color: #FFFFFF;
    text-decoration: none;
}

body.portal-body .btn-small {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border-strong);
    border-radius: 999px;
    color: var(--portal-heading);
    font-weight: 700;
    padding: 8px 14px;
    text-align: center;
    text-decoration: none;
}

body.portal-body .btn-small:hover {
    background: #FCEBF4;
    border-color: var(--portal-primary);
    color: var(--portal-primary-hover);
    text-decoration: none;
}

body.portal-body .btn-small.btn-primary {
    background: var(--portal-primary);
    border-color: var(--portal-primary);
    color: #FFFFFF;
}

body.portal-body .btn-small.btn-primary:hover {
    background: var(--portal-primary-hover);
    border-color: var(--portal-primary-hover);
    color: #FFFFFF;
}

body.portal-body .btn-danger,
body.portal-body .btn-small.btn-danger {
    background: #FDECEF;
    border-color: #F0B4C1;
    color: #9F243F;
}

body.portal-body .btn-danger:hover,
body.portal-body .btn-small.btn-danger:hover {
    background: #F8D7DF;
    border-color: #D86F86;
    color: #7F1730;
}

body.portal-body .action-links {
    gap: 10px;
    margin-top: 18px;
}

body.portal-body .table-responsive {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    overflow-x: auto;
}

body.portal-body .data-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 680px;
}

body.portal-body .data-table th {
    background: #E9D8F4;
    border-bottom: 1px solid var(--portal-border);
    color: #5E2B70;
    font-size: 12px;
    letter-spacing: 0.04em;
}

body.portal-body .data-table td {
    border-bottom: 1px solid #F1DDEC;
    color: var(--portal-text);
    vertical-align: top;
}

body.portal-body .data-table tbody tr:nth-child(even) {
    background: var(--portal-surface-soft);
}

body.portal-body .data-table tbody tr:hover {
    background: #FFF2F8;
}

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

body.portal-body .data-table td:last-child {
    overflow-wrap: anywhere;
}

body.portal-body .badge {
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 700;
}

body.portal-body .badge-secondary {
    background: var(--portal-surface-warm);
    border-color: var(--portal-highlight-border);
    color: #6E5A25;
}

body.portal-body .badge-primary {
    background: #F9E1F0;
    border-color: var(--portal-border-strong);
    color: var(--portal-primary-hover);
}

body.portal-body .badge-success {
    background: #EDF8EE;
    border-color: #B8DFC0;
    color: #2F6C3B;
}

body.portal-body .badge-warning {
    background: var(--portal-highlight);
    border-color: var(--portal-highlight-border);
    color: #6E5A25;
}

body.portal-body .badge-info {
    background: #F2ECFA;
    border-color: #D9C3EC;
    color: var(--portal-heading);
}

body.portal-body .badge-danger {
    background: #FDECEF;
    border-color: #F0B4C1;
    color: #9F243F;
}

body.portal-body .empty-message {
    background: var(--portal-surface-soft);
    border: 1px dashed var(--portal-border-strong);
    border-radius: 16px;
    color: var(--portal-muted);
}

body.portal-body .success-message {
    background: #EDF8EE;
    border: 1px solid #B8DFC0;
    border-radius: 12px;
    color: #2F6C3B;
    display: block;
    line-height: 1.45;
    margin-bottom: 20px;
    margin-top: 0;
    overflow-wrap: anywhere;
    padding: 14px 16px;
    text-align: left;
}

body.portal-body .error-message {
    background: #FDECEF;
    border: 1px solid #F0B4C1;
    border-radius: 12px;
    color: #9F243F;
    text-align: left;
}

body.portal-body .back-link a {
    display: inline-block;
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border-strong);
    border-radius: 999px;
    color: var(--portal-heading);
    font-weight: 700;
    padding: 9px 14px;
    text-decoration: none;
}

body.portal-body .back-link a:hover {
    background: #FCEBF4;
    color: var(--portal-primary-hover);
}

body.portal-body .report-text-block {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    color: var(--portal-text);
    line-height: 1.58;
    padding: 14px;
}

body.portal-body .portal-summary-panel {
    background: var(--portal-highlight);
    border-color: var(--portal-highlight-border);
}

body.portal-body .portal-summary-panel .report-text-block {
    background: rgba(255, 255, 255, 0.58);
    border-color: var(--portal-highlight-border);
}

body.portal-body .portal-report-list,
body.portal-body .portal-chat-history {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

body.portal-body .portal-chat-header {
    flex: 0 0 auto;
    margin-bottom: 10px;
    padding: 12px 18px;
}

body.portal-body .portal-chat-header h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

body.portal-body .portal-chat-header .subtitle {
    font-size: 13px;
    line-height: 1.35;
}

body.portal-body .portal-chat-shell {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 20px;
    box-shadow: var(--portal-shadow-soft);
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

body.portal-body .portal-chat-history {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    overscroll-behavior: contain;
}

body.portal-body .portal-chat-input-bar {
    border-top: 1px solid var(--portal-border);
    flex: 0 0 auto;
    padding: 14px 18px 18px;
}

body.portal-body .portal-chat-input-bar label {
    color: var(--portal-heading);
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

body.portal-body .portal-chat-input-row {
    align-items: flex-end;
    display: flex;
    gap: 12px;
}

body.portal-body .portal-chat-input-row textarea {
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    color: var(--portal-text);
    flex: 1 1 auto;
    font: inherit;
    min-height: 52px;
    min-width: 0;
    padding: 12px 14px;
    resize: vertical;
}

body.portal-body .portal-chat-input-row textarea:focus {
    border-color: var(--portal-primary);
    box-shadow: var(--portal-focus-ring);
    outline: none;
}

body.portal-body .portal-report-card {
    align-items: center;
    border-left: 6px solid var(--portal-primary);
    display: flex;
    gap: 20px;
    justify-content: space-between;
}

body.portal-body .portal-report-card h2 {
    margin-bottom: 0;
    overflow-wrap: anywhere;
}

body.portal-body .portal-kicker {
    color: var(--portal-muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

body.portal-body .portal-report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

body.portal-body .portal-report-meta span {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 999px;
    color: var(--portal-muted);
    font-size: 13px;
    padding: 6px 10px;
}

body.portal-body .portal-report-actions {
    align-items: center;
    justify-content: flex-end;
    margin-top: 0;
}

body.portal-body .portal-report-section {
    background: var(--portal-surface-soft);
    margin-bottom: 16px;
}

body.portal-body .portal-report-section:last-child {
    margin-bottom: 0;
}

body.portal-body .portal-chat-message {
    border: 1px solid var(--portal-border);
    border-radius: 18px;
    box-shadow: var(--portal-shadow-soft);
    max-width: 82%;
    padding: 14px 16px;
}

body.portal-body .portal-chat-message-user {
    align-self: flex-end;
    background: #FFF2F8;
    border-color: var(--portal-border-strong);
}

body.portal-body .portal-chat-message-assistant {
    align-self: flex-start;
    background: var(--portal-surface);
}

body.portal-body .portal-chat-meta {
    align-items: center;
    color: var(--portal-muted);
    display: flex;
    font-size: 12px;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 8px;
}

body.portal-body .portal-chat-meta span {
    color: var(--portal-heading);
    font-weight: 700;
}

body.portal-body .portal-chat-message-user .portal-chat-meta span {
    color: var(--portal-primary-hover);
}

body.portal-body .portal-chat-text {
    color: var(--portal-text);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

body.portal-body .portal-chat-message-user .portal-chat-text {
    white-space: pre-wrap;
}

body.portal-body .portal-chat-text p,
body.portal-body .portal-chat-text ul,
body.portal-body .portal-chat-text ol,
body.portal-body .portal-chat-text pre,
body.portal-body .portal-chat-text table {
    margin: 0 0 10px;
}

body.portal-body .portal-chat-text p:last-child,
body.portal-body .portal-chat-text ul:last-child,
body.portal-body .portal-chat-text ol:last-child,
body.portal-body .portal-chat-text pre:last-child,
body.portal-body .portal-chat-text table:last-child {
    margin-bottom: 0;
}

body.portal-body .portal-chat-text ul,
body.portal-body .portal-chat-text ol {
    padding-left: 20px;
}

body.portal-body .portal-chat-text h1,
body.portal-body .portal-chat-text h2,
body.portal-body .portal-chat-text h3,
body.portal-body .portal-chat-text h4,
body.portal-body .portal-chat-text h5,
body.portal-body .portal-chat-text h6 {
    color: var(--portal-heading);
    font-size: 1rem;
    margin: 0 0 8px;
}

body.portal-body .portal-chat-text hr {
    border: 0;
    border-top: 1px solid var(--portal-border);
    margin: 12px 0;
}

body.portal-body .portal-chat-text pre {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    overflow-x: auto;
    padding: 10px;
}

body.portal-body .portal-chat-text pre code {
    background: transparent;
    border: 0;
    padding: 0;
}

body.portal-body .portal-chat-text table {
    border-collapse: collapse;
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

body.portal-body .portal-chat-text th,
body.portal-body .portal-chat-text td {
    border: 1px solid var(--portal-border);
    padding: 6px 8px;
    text-align: left;
}

body.portal-body .portal-chat-text th {
    background: var(--portal-surface-soft);
}

body.portal-body .portal-chat-text code {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
    font-size: 0.92em;
    padding: 1px 5px;
}

@media (max-width: 768px) {
    body.portal-body .nav-bar {
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
    }

    body.portal-body .nav-menu,
    body.portal-body .portal-nav-menu {
        display: flex;
        justify-content: flex-end;
        width: auto;
    }

    body.portal-body .container {
        padding: 20px 14px 36px;
    }

    body.portal-body.portal-chat-page .container {
        height: calc(100dvh - var(--portal-nav-height, 50px));
        padding: 10px 8px 8px;
    }

    body.portal-body .portal-chat-header {
        border-left-width: 4px;
        margin-bottom: 8px;
        padding: 8px 12px;
    }

    body.portal-body .portal-chat-header h1 {
        font-size: 19px;
    }

    body.portal-body .portal-chat-input-row {
        align-items: stretch;
        flex-direction: row;
        gap: 8px;
    }

    body.portal-body .dashboard-header,
    body.portal-body .dashboard-section,
    body.portal-body .dashboard-content,
    body.portal-body .detail-card {
        border-radius: 18px;
        padding: 18px;
    }

    body.portal-body .dashboard-header h1 {
        font-size: 24px;
    }

    body.portal-body .portal-report-card {
        align-items: stretch;
        flex-direction: column;
    }

    body.portal-body .portal-report-actions {
        justify-content: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
    }

    body.portal-body .portal-report-actions .btn-primary,
    body.portal-body .portal-report-actions .btn-small {
        flex: 0 1 auto;
        padding: 8px 12px;
        width: auto;
    }

    body.portal-body .portal-chat-message {
        max-width: 92%;
    }
}

@media (max-width: 480px) {
    body.portal-body .nav-brand {
        font-size: 16px;
    }

    body.portal-body .portal-nav-link {
        font-size: 13px;
        padding: 6px 8px;
    }

    body.portal-body .portal-nav-link {
        text-align: center;
    }

    body.portal-body .action-links {
        align-items: stretch;
        flex-direction: column;
    }

    body.portal-body .action-links .btn-primary,
    body.portal-body .action-links .btn-small,
    body.portal-body .form-vertical .btn-primary {
        width: 100%;
    }

    body.portal-body .portal-report-actions .btn-primary,
    body.portal-body .portal-report-actions .btn-small {
        flex: 0 1 auto;
        width: auto;
    }

    body.portal-body .portal-chat-message {
        max-width: 100%;
    }

    body.portal-body .data-table {
        min-width: 620px;
    }
}

/* Participant portal staged test flow */
body.portal-body .portal-chat-nav-link {
    align-items: center;
    display: inline-flex;
    gap: 6px;
    min-height: 34px;
}

body.portal-body .portal-unread-badge {
    align-items: center;
    background: var(--portal-primary);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    justify-content: center;
    min-height: 20px;
    min-width: 20px;
    padding: 2px 6px;
}

body.portal-body .portal-final-report,
body.portal-body .portal-stage-card,
body.portal-body .portal-submit-card {
    margin-bottom: 22px;
}

body.portal-body .portal-final-report {
    align-items: center;
    border-left: 6px solid var(--portal-primary);
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

body.portal-body .portal-final-report-generating {
    border-left-color: var(--portal-highlight-border);
}

body.portal-body .portal-final-report-error {
    border-left-color: #D86F86;
}

body.portal-body .portal-stage-heading {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

body.portal-body .portal-progress {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 999px;
    height: 18px;
    margin: 18px 0 8px;
    overflow: hidden;
}

body.portal-body .portal-progress-fill {
    background: linear-gradient(90deg, var(--portal-primary), #F09AC7);
    border-radius: inherit;
    height: 100%;
    min-width: 0;
    transition: width 0.25s ease;
}

body.portal-body .portal-progress-label {
    color: var(--portal-muted);
    font-size: 14px;
    margin-bottom: 18px;
}

body.portal-body .portal-test-checklist {
    display: grid;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
}

body.portal-body .portal-test-item {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    overflow: hidden;
}

body.portal-body .portal-test-item.is-complete {
    background: #fff;
    border-color: var(--portal-border-strong);
}

body.portal-body .portal-test-details summary,
body.portal-body .portal-test-empty {
    align-items: center;
    color: var(--portal-heading);
    cursor: pointer;
    display: flex;
    font-weight: 800;
    gap: 10px;
    min-height: 52px;
    padding: 14px 16px;
}

body.portal-body .portal-test-empty {
    color: var(--portal-muted);
    cursor: default;
}

body.portal-body .portal-test-mark {
    flex: 0 0 auto;
    width: 24px;
}

body.portal-body .portal-test-mark.neutral::before {
    background: var(--portal-border);
    border-radius: 999px;
    content: "";
    display: block;
    height: 10px;
    margin-left: 4px;
    width: 10px;
}

body.portal-body .portal-result-panel {
    border-top: 1px solid var(--portal-border);
    padding: 0 16px 16px;
}

body.portal-body .portal-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

body.portal-body .portal-result-meta span {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 999px;
    color: var(--portal-muted);
    font-size: 13px;
    padding: 6px 10px;
}

body.portal-body .portal-result-table-wrap {
    max-width: 100%;
}

body.portal-body .portal-luscher-block {
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    margin-top: 14px;
    padding: 16px;
}

body.portal-body .portal-luscher-grid {
    display: grid;
    gap: 8px 14px;
    grid-template-columns: minmax(130px, 0.35fr) 1fr;
    margin: 12px 0 0;
}

body.portal-body .portal-luscher-grid dt {
    color: var(--portal-muted);
    font-weight: 800;
}

body.portal-body .portal-luscher-grid dd {
    overflow-wrap: anywhere;
}

body.portal-body .portal-interpretation-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

body.portal-body .portal-interpretation-list article,
body.portal-body .portal-interpretation-list > p {
    background: #fff;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 12px;
}

body.portal-body .portal-stage-action {
    margin-top: 18px;
}

body.portal-body .portal-submit-card textarea {
    min-height: 150px;
}

body.portal-body .portal-submission-results {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

body.portal-body .portal-submission-result {
    align-items: flex-start;
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 14px;
}

body.portal-body .portal-submission-result-accepted {
    background: #EDF8EE;
    border-color: #B8DFC0;
}

body.portal-body .portal-submission-result-duplicate {
    background: var(--portal-highlight);
    border-color: var(--portal-highlight-border);
}

body.portal-body .portal-submission-result-error {
    background: #FDECEF;
    border-color: #F0B4C1;
}

body.portal-body .portal-submission-url {
    color: var(--portal-muted);
    font-size: 13px;
    margin: 8px 0;
    overflow-wrap: anywhere;
}

body.portal-body .portal-submission-accepted-label {
    color: var(--portal-muted);
    font-size: 13px;
    font-weight: 700;
    margin-left: 8px;
}

body.portal-body .portal-duplicate-actions {
    flex: 0 0 auto;
    margin-top: 0;
}

/* Participant portal dynamic chat */
body.portal-body .portal-chat-shell {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 18px;
    box-shadow: var(--portal-shadow-soft);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 220px);
    overflow: hidden;
}

body.portal-body .portal-chat-history-live {
    flex: 1 1 auto;
    max-height: calc(100vh - 320px);
    min-height: 320px;
    overflow-y: auto;
    padding: 14px;
}

body.portal-body .portal-chat-input-bar {
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--portal-border);
    bottom: 0;
    padding: 10px;
    position: sticky;
}

body.portal-body .portal-chat-input-bar label {
    color: var(--portal-heading);
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 8px;
}

body.portal-body .portal-chat-input-row {
    align-items: flex-end;
    display: flex;
    gap: 10px;
}

body.portal-body .portal-chat-input-row textarea {
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    color: var(--portal-text);
    flex: 1 1 auto;
    font: inherit;
    min-height: 46px;
    min-width: 0;
    padding: 10px;
    resize: vertical;
}

body.portal-body .portal-chat-input-row textarea:focus {
    border-color: var(--portal-primary);
    box-shadow: var(--portal-focus-ring);
    outline: none;
}

body.portal-body .portal-chat-input-row .btn-primary {
    min-height: 46px;
}

body.portal-body .typing-dots {
    align-items: center;
    display: inline-flex;
    gap: 5px;
    min-height: 24px;
}

body.portal-body .typing-dots span {
    animation: portalTypingDots 1s infinite ease-in-out;
    background: var(--portal-primary);
    border-radius: 999px;
    display: block;
    height: 7px;
    width: 7px;
}

body.portal-body .typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

body.portal-body .typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes portalTypingDots {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 768px) {
    body.portal-body .portal-final-report,
    body.portal-body .portal-submission-result,
    body.portal-body .portal-stage-heading {
        align-items: stretch;
        flex-direction: column;
    }

    body.portal-body .portal-chat-shell {
        min-height: calc(100vh - 190px);
    }

    body.portal-body .portal-chat-history-live {
        max-height: calc(100vh - 300px);
        min-height: 300px;
        padding: 10px;
    }

    body.portal-body .portal-luscher-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body.portal-body .portal-nav-menu {
        gap: 6px;
    }

    body.portal-body .portal-chat-input-row {
        flex-direction: column;
    }

    body.portal-body .portal-chat-input-row textarea,
    body.portal-body .portal-chat-input-row .btn-primary {
        width: 100%;
    }

    body.portal-body .portal-chat-input-bar {
        padding: 8px;
    }

    body.portal-body .portal-result-panel {
        padding: 0 10px 12px;
    }

    body.portal-body .portal-test-details summary,
    body.portal-body .portal-test-empty {
        min-height: 48px;
        padding: 12px;
    }
}

body.portal-body.portal-chat-page .portal-chat-shell {
    flex: 1 1 auto;
    min-height: 0;
}

body.portal-body.portal-chat-page .portal-chat-history-live {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
}

body.portal-body.portal-chat-page .portal-chat-input-bar {
    flex: 0 0 auto;
    position: static;
}

/* Final admin visual layer. Keep this after legacy and portal rules. */
body.admin-body {
    --admin-accent: #733a79;
    --admin-accent-dark: #5c2863;
    --admin-accent-soft: #f1e8f3;
    --admin-sidebar: #2a1f2e;
    --admin-sidebar-active: #3a2b40;
    --admin-surface: #fff;
    --admin-surface-soft: #faf9fc;
    --admin-border: #e6e1e9;
    --admin-text: #29242d;
    --admin-muted: #716a76;
    --admin-success: #317455;
    --admin-warning: #9a651b;
    background: #f6f5f8;
    color: var(--admin-text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.admin-body a {
    color: var(--admin-accent);
    text-decoration-color: rgba(115, 58, 121, .35);
    text-underline-offset: 2px;
}

body.admin-body a:hover { color: var(--admin-accent-dark); }

body.admin-body .sidebar {
    background: var(--admin-sidebar);
    border-right: 0;
    color: #f8f3f9;
    padding: 20px 14px 16px;
    width: 230px;
}

body.admin-body .admin-brand {
    align-items: center;
    display: flex;
    gap: 11px;
    padding: 0 3px 24px;
}

body.admin-body .admin-brand-mark {
    align-items: center;
    background: linear-gradient(145deg, #9d66a3, #6f3576);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(9, 4, 12, .25);
    display: flex;
    flex: 0 0 auto;
    font-family: Georgia, serif;
    font-size: 24px;
    height: 42px;
    justify-content: center;
    width: 42px;
}

body.admin-body .admin-brand-copy { display: grid; line-height: 1.2; }
body.admin-body .admin-brand-copy strong { color: #fff; font-size: 13px; }
body.admin-body .admin-brand-copy small { color: #bdaec2; font-size: 10px; margin-top: 3px; }
body.admin-body .sidebar-nav { padding: 0; }
body.admin-body .sidebar-label {
    color: #96879b;
    display: block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    margin: 0 10px 7px;
    text-transform: uppercase;
}
body.admin-body .sidebar-label-system { margin-top: 18px; }
body.admin-body .sidebar-link {
    align-items: center;
    border: 0;
    border-radius: 9px;
    color: #d8cedb;
    display: flex;
    gap: 10px;
    margin: 2px 0;
    min-height: 39px;
    padding: 8px 10px;
}
body.admin-body .sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
body.admin-body .sidebar-link.is-active {
    background: var(--admin-sidebar-active);
    border: 0;
    box-shadow: inset 3px 0 #c58aca;
    color: #fff;
}
body.admin-body .sidebar-icon { color: #b7a8bb; display: inline-flex; justify-content: center; width: 20px; }
body.admin-body .sidebar-link.is-active .sidebar-icon { color: #e4b8e8; }
body.admin-body .sidebar-footer {
    border-color: rgba(255, 255, 255, .1);
    gap: 9px;
    padding: 15px 2px 0;
}
body.admin-body .admin-avatar {
    align-items: center;
    background: #e9d6ec;
    border-radius: 50%;
    color: #5f2d66;
    display: flex;
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}
body.admin-body .sidebar-user { display: grid; min-width: 0; }
body.admin-body .sidebar-user strong { color: #fff; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
body.admin-body .sidebar-user small { color: #a99cad; font-size: 10px; }
body.admin-body .nav-logout-button { color: #dcb9df; font-size: 11px; }
body.admin-body .admin-topbar {
    align-items: center;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--admin-border);
    color: var(--admin-muted);
    display: flex;
    font-size: 12px;
    height: 58px;
    left: 230px;
    padding: 0 30px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 100;
}

body.admin-body input:not([type="checkbox"]):not([type="radio"]),
body.admin-body select,
body.admin-body textarea {
    background-color: #fff;
    border: 1px solid #d9d2dc;
    border-radius: 9px;
    color: var(--admin-text);
    font: inherit;
}

body.admin-body select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%23733a79' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    padding: 9px 38px 9px 11px;
}

body.admin-body input:not([type="checkbox"]):not([type="radio"]):focus,
body.admin-body select:focus,
body.admin-body textarea:focus,
body.admin-body .sql-editor:focus,
body.admin-body .save-form input:focus,
body.admin-body .save-form textarea:focus {
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 3px rgba(115, 58, 121, .12);
    outline: 0;
}

body.admin-body .btn-primary,
body.admin-body .login-btn,
body.admin-body .btn-commit {
    background: var(--admin-accent);
    border: 1px solid var(--admin-accent);
    border-radius: 9px;
    box-shadow: 0 5px 14px rgba(92, 40, 99, .14);
    color: #fff;
}
body.admin-body .btn-primary:hover,
body.admin-body .login-btn:hover,
body.admin-body .btn-commit:hover { background: var(--admin-accent-dark); border-color: var(--admin-accent-dark); }
body.admin-body .btn-small,
body.admin-body .pagination-link {
    background: var(--admin-accent-soft);
    border: 1px solid #dbcfe5;
    border-radius: 9px;
    color: var(--admin-accent-dark);
}
body.admin-body .btn-small:hover,
body.admin-body .pagination-link:hover { background: #e5d9e9; border-color: #cbb9d3; color: #48204e; }
body.admin-body .btn-danger { background: #fbecef; border-color: #efcbd1; color: #a63f4c; }
body.admin-body .action-link { background: #fff; border-color: #ddd6e0; color: #4e4752; }
body.admin-body .action-link:hover { background: var(--admin-accent-soft); border-color: #d7c5dc; color: var(--admin-accent-dark); }
body.admin-body .filter-bar .btn-small { background: var(--admin-accent); border-color: var(--admin-accent); color: #fff; }

body.admin-body .data-table th,
body.admin-body .results-table th,
body.admin-body .preview-table th {
    background: var(--admin-surface-soft);
    border-color: var(--admin-border);
    color: #5f5665;
}
body.admin-body .data-table td,
body.admin-body .results-table td,
body.admin-body .preview-table td { border-color: var(--admin-border); }
body.admin-body .data-table tr:hover,
body.admin-body .preview-table tr:hover { background: #f7f2f8; }
body.admin-body .data-table a,
body.admin-body .cohort-list td:first-child a { color: var(--admin-accent); font-weight: 700; text-decoration: none; }
body.admin-body .data-table a:hover,
body.admin-body .cohort-list td:first-child a:hover { color: var(--admin-accent-dark); text-decoration: underline; }
body.admin-body .stage-count,
body.admin-body .stat-value { color: var(--admin-accent); }
body.admin-body .message-user { background: var(--admin-accent-soft); }

body.admin-body .import-container { margin: 0; max-width: none; padding: 0; }
body.admin-body #uploadForm { display: block; width: 100%; }
body.admin-body .upload-area {
    align-items: center;
    background: #fcfafd;
    border-color: #cdbdd1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    min-height: 280px;
    padding: 38px 24px;
    width: 100%;
}
body.admin-body .upload-area:hover { background: #f7f0f8; border-color: var(--admin-accent); }
body.admin-body .upload-icon { color: var(--admin-accent); }
body.admin-body .conflict-btn.active { background: var(--admin-accent); border-color: var(--admin-accent); }

body.admin-body .participant-page-heading {
    align-items: flex-start;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 18px;
}
body.admin-body .participant-page-heading h1 { font-size: 27px; letter-spacing: -.025em; margin: 0 0 7px; }
body.admin-body .participant-heading-meta { align-items: center; color: var(--admin-muted); display: flex; flex-wrap: wrap; font-size: 13px; gap: 7px; margin: 0; }
body.admin-body .participant-heading-meta i { background: #c3bdc6; border-radius: 50%; height: 3px; width: 3px; }
body.admin-body .participant-heading-actions { display: flex; flex: 0 0 auto; gap: 9px; }
body.admin-body .admin-button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    gap: 7px;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    text-decoration: none;
}
body.admin-body .admin-button-primary { background: var(--admin-accent); box-shadow: 0 5px 14px rgba(92, 40, 99, .17); color: #fff; }
body.admin-body .admin-button-primary:hover { background: var(--admin-accent-dark); color: #fff; }
body.admin-body .admin-button-secondary { background: #fff; border-color: #d9d2dc; color: #4e4752; }
body.admin-body .admin-button-secondary:hover { background: var(--admin-accent-soft); color: var(--admin-accent-dark); }
body.admin-body .admin-button-small { font-size: 12px; min-height: 34px; padding: 6px 10px; }
body.admin-body .participant-summary-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
body.admin-body .participant-summary-card {
    align-items: center;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 11px;
    display: flex;
    gap: 12px;
    min-height: 76px;
    padding: 13px 15px;
}
body.admin-body .participant-summary-icon { align-items: center; background: var(--admin-accent-soft); border-radius: 9px; color: var(--admin-accent); display: flex; flex: 0 0 auto; font-size: 16px; height: 38px; justify-content: center; width: 38px; }
body.admin-body .participant-summary-card div { display: grid; }
body.admin-body .participant-summary-card small { color: var(--admin-muted); font-size: 11px; }
body.admin-body .participant-summary-card strong { font-size: 15px; line-height: 1.25; }
body.admin-body .participant-summary-card span:not(.participant-summary-icon) { color: #98919c; font-size: 11px; }
body.admin-body .participant-notice { align-items: center; background: #fff5df; border: 1px solid #ecdcb8; border-radius: 10px; color: #604b2c; display: flex; gap: 11px; margin-bottom: 14px; min-height: 44px; padding: 9px 13px; }
body.admin-body .participant-notice-icon { align-items: center; background: #ffe8b8; border-radius: 7px; color: var(--admin-warning); display: flex; flex: 0 0 auto; height: 28px; justify-content: center; width: 28px; }
body.admin-body .participant-notice a { color: #79500e; font-size: 12px; font-weight: 700; margin-left: auto; white-space: nowrap; }
body.admin-body .participant-workspace { align-items: start; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) 350px; }
body.admin-body .participant-card { background: #fff; border: 1px solid var(--admin-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(30, 20, 34, .04), 0 8px 24px rgba(30, 20, 34, .05); overflow: hidden; }
body.admin-body .participant-card-header { align-items: center; border-bottom: 1px solid var(--admin-border); display: flex; justify-content: space-between; min-height: 58px; padding: 13px 17px; }
body.admin-body .participant-card-header h2 { font-size: 16px; margin: 0; }
body.admin-body .participant-card-header p { color: var(--admin-muted); font-size: 11px; margin: 2px 0 0; }
body.admin-body .participant-card-header a { font-size: 11px; font-weight: 700; text-decoration: none; }
body.admin-body .participant-segment { background: #fff; border: 3px solid #f1eff3; border-radius: 8px; color: var(--admin-text); font-size: 11px; font-weight: 700; padding: 5px 9px; }
body.admin-body .participant-progress { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 15px 17px 8px; }
body.admin-body .participant-progress > div:first-child { padding-right: 8px; }
body.admin-body .participant-progress > div:last-child { padding-left: 8px; }
body.admin-body .participant-progress-track { background: #e9e5eb; border-radius: 99px; display: block; height: 5px; margin-bottom: 8px; overflow: hidden; }
body.admin-body .participant-progress-track i { background: var(--admin-success); border-radius: inherit; display: block; height: 100%; }
body.admin-body .participant-progress-track i.is-warning { background: #c58c35; }
body.admin-body .participant-progress strong,
body.admin-body .participant-progress small { display: block; }
body.admin-body .participant-progress strong { font-size: 12px; }
body.admin-body .participant-progress small { color: var(--admin-muted); font-size: 11px; }
body.admin-body .participant-results-table { border-collapse: collapse; width: 100%; }
body.admin-body .participant-results-table th { background: var(--admin-surface-soft); color: var(--admin-muted); font-size: 10px; letter-spacing: .06em; padding: 10px 17px; text-align: left; text-transform: uppercase; }
body.admin-body .participant-results-table td { border-top: 1px solid var(--admin-border); padding: 12px 17px; vertical-align: middle; }
body.admin-body .participant-results-table td > strong,
body.admin-body .participant-results-table td > small { display: block; }
body.admin-body .participant-results-table td > small { color: var(--admin-muted); font-size: 11px; }
body.admin-body .participant-result-state { align-items: center; display: flex; font-size: 12px; font-weight: 700; gap: 7px; }
body.admin-body .participant-result-state i { background: var(--admin-success); border: 3px solid #e9f5ee; border-radius: 50%; height: 11px; width: 11px; }
body.admin-body .participant-result-state.is-pending i { background: #c58c35; border-color: #fff5df; }
body.admin-body .participant-scales { position: relative; }
body.admin-body .participant-scales summary { color: var(--admin-accent); cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; }
body.admin-body .participant-scales div { background: #fff; border: 1px solid var(--admin-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(30, 20, 34, .12); display: grid; gap: 4px; min-width: 220px; padding: 10px; position: absolute; right: 0; top: 25px; z-index: 4; }
body.admin-body .participant-scales div span { font-size: 11px; }
body.admin-body .participant-table-footer { align-items: center; background: var(--admin-surface-soft); border-top: 1px solid var(--admin-border); color: var(--admin-muted); display: flex; font-size: 11px; justify-content: space-between; min-height: 46px; padding: 8px 17px; }
body.admin-body .participant-table-footer a { font-weight: 700; text-decoration: none; }
body.admin-body .participant-side-stack { display: grid; gap: 14px; }
body.admin-body .participant-report-list { padding: 4px 15px 9px; }
body.admin-body .participant-report-item { border-bottom: 1px solid var(--admin-border); padding: 13px 2px; }
body.admin-body .participant-report-item:last-child { border-bottom: 0; }
body.admin-body .participant-report-topline { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
body.admin-body .participant-report-topline > strong { font-size: 13px; }
body.admin-body .participant-report-item > p { color: var(--admin-muted); font-size: 11px; margin: 4px 0 7px; }
body.admin-body .participant-report-progress { background: #ece8ee; border-radius: 99px; height: 4px; margin: 9px 0 7px; overflow: hidden; }
body.admin-body .participant-report-progress i { background: linear-gradient(90deg, #8a4f90, #bd84c2); display: block; height: 100%; width: 66%; }
body.admin-body .participant-auto-update { align-items: center; background: #f4edf5; border-radius: 8px; color: #725376; display: flex; font-size: 10px; gap: 7px; margin: 3px 0 8px; padding: 8px 9px; }
body.admin-body .status-pulse { animation: pulse 1.8s infinite; background: currentColor; border-radius: 50%; display: inline-block; height: 5px; width: 5px; }
body.admin-body .participant-activity-list { padding: 7px 16px 12px; }
body.admin-body .participant-activity-list > div { display: grid; gap: 9px; grid-template-columns: 26px 1fr; padding: 8px 0; }
body.admin-body .participant-activity-list > div > span { align-items: center; background: var(--admin-accent-soft); border-radius: 7px; color: var(--admin-accent); display: flex; font-size: 11px; height: 26px; justify-content: center; width: 26px; }
body.admin-body .participant-activity-list p { font-size: 11px; margin: 0; }
body.admin-body .participant-activity-list small { color: #98919c; display: block; font-size: 10px; margin-top: 2px; }
body.admin-body .participant-upload-panel { background: #fff; border: 1px solid var(--admin-border); border-radius: 12px; margin-top: 14px; padding: 16px; }
body.admin-body .participant-upload-panel > summary { color: var(--admin-accent); cursor: pointer; font-weight: 700; }
body.admin-body .participant-upload-panel[open] > summary { border-bottom: 1px solid var(--admin-border); margin-bottom: 16px; padding-bottom: 14px; }
body.admin-body .participant-upload-panel .adolescent-uploader { border: 0; box-shadow: none; margin: 0; padding: 0; }
body.admin-body .cohort-overview {
    align-items: flex-start;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 22px;
}
body.admin-body .cohort-overview h1 { font-size: 27px; letter-spacing: -.025em; margin: 0 0 7px; }
body.admin-body .cohort-overview > div > p { color: var(--admin-muted); margin: 0 0 7px; }
body.admin-body .cohort-overview-meta { align-items: center; color: var(--admin-muted); display: flex; flex-wrap: wrap; font-size: 12px; gap: 7px; }
body.admin-body .cohort-overview-meta i { background: #c3bdc6; border-radius: 50%; height: 3px; width: 3px; }
body.admin-body .cohort-settings { flex: 0 0 auto; position: relative; }
body.admin-body .cohort-overview.participant-card { overflow: visible; }
body.admin-body .cohort-settings .cohort-settings-close {
    align-items: center;
    background: #f4f2f5;
    border: 1px solid var(--admin-border);
    border-radius: 50%;
    color: var(--admin-muted);
    cursor: pointer;
    display: none;
    font-size: 16px;
    height: 26px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    position: absolute;
    right: 10px;
    top: 10px;
    width: 26px;
    z-index: 6;
}
body.admin-body .cohort-settings[open] .cohort-settings-close { display: flex; }
body.admin-body .cohort-settings .cohort-settings-close:hover { background: #e9e5eb; color: #333; }
body.admin-body .cohort-settings .form-group label.checkbox-row { align-items: center; display: flex; gap: 8px; }
body.admin-body .cohort-settings .form-group label.checkbox-row input[type=checkbox] { box-sizing: border-box; flex: 0 0 auto; height: 16px; margin: 0; padding: 0; width: 16px; }
body.admin-body .cohort-settings summary,
body.admin-body .cohort-add-member summary { list-style: none; }
body.admin-body .cohort-settings summary::-webkit-details-marker,
body.admin-body .cohort-add-member summary::-webkit-details-marker { display: none; }
body.admin-body .cohort-settings[open] > summary { display: none; }
body.admin-body .cohort-settings form {
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(30, 20, 34, .16);
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding: 18px;
    position: absolute;
    right: 0;
    top: 0;
    width: min(420px, calc(100vw - 60px));
    z-index: 5;
}
body.admin-body .cohort-members { margin-bottom: 20px; }
body.admin-body .cohort-add-member { position: relative; }
body.admin-body .cohort-add-member[open] > summary { background: var(--admin-accent-dark); color: #fff; }
body.admin-body .cohort-add-member form,
body.admin-body .cohort-add-member .empty-message {
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(30, 20, 34, .16);
    margin: 10px 0 0;
    padding: 16px;
    position: absolute;
    right: 0;
    top: 40px;
    width: min(460px, calc(100vw - 60px));
    z-index: 5;
}
body.admin-body .cohort-members-table { border-collapse: collapse; width: 100%; }
body.admin-body .cohort-members-table th { background: var(--admin-surface-soft); color: var(--admin-muted); font-size: 10px; letter-spacing: .06em; padding: 10px 17px; text-align: left; text-transform: uppercase; }
body.admin-body .cohort-members-table td { border-top: 1px solid var(--admin-border); padding: 12px 17px; vertical-align: middle; }
body.admin-body .cohort-members-table td:first-child > strong,
body.admin-body .cohort-members-table td:first-child > small { display: block; }
body.admin-body .cohort-members-table td:first-child > small { color: var(--admin-muted); font-size: 11px; margin-top: 2px; }
body.admin-body .cohort-member-link { color: var(--admin-text); text-decoration-color: #c7a9ca; text-underline-offset: 3px; }
body.admin-body .cohort-member-link:hover { color: var(--admin-accent); }
body.admin-body .cohort-stage { border-radius: 999px; display: inline-flex; font-size: 11px; font-weight: 700; padding: 5px 8px; white-space: nowrap; }
body.admin-body .cohort-stage-success { background: #e9f5ee; color: var(--admin-success); }
body.admin-body .cohort-stage-warning { background: #fff5df; color: var(--admin-warning); }
body.admin-body .cohort-stage-info { background: #f1e8f3; color: var(--admin-accent); }
body.admin-body .cohort-stage-muted { background: #efedf1; color: var(--admin-muted); }
body.admin-body .cohort-member-progress { display: grid; gap: 7px; min-width: 165px; }
body.admin-body .cohort-member-progress > span { position: relative; }
body.admin-body .cohort-member-progress > span::before { background: #e9e5eb; border-radius: 99px; content: ""; display: block; height: 5px; }
body.admin-body .cohort-member-progress i { background: var(--admin-success); border-radius: 99px; display: block; height: 5px; left: 0; position: absolute; top: 0; }
body.admin-body .cohort-member-progress i.is-warning { background: #c58c35; }
body.admin-body .cohort-member-progress small { color: var(--admin-muted); display: block; font-size: 10px; margin-top: 3px; }

@media (min-width: 1200px) {
    body.admin-body .container { margin: 58px 0 0 230px; max-width: none; padding: 22px 30px 40px; width: calc(100% - 230px); }
}

@media (max-width: 1199px) {
    body.admin-body .admin-topbar { display: none; }
    body.admin-body .sidebar { width: 250px; }
    body.admin-body .nav-bar { border-bottom: 1px solid var(--admin-border); }
    body.admin-body .participant-workspace { grid-template-columns: minmax(0, 1fr) 310px; }
}

@media (max-width: 860px) {
    body.admin-body .participant-workspace { grid-template-columns: 1fr; }
    body.admin-body .participant-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body.admin-body .participant-page-heading { flex-direction: column; }
    body.admin-body .cohort-overview { flex-direction: column; }
}
