/* Define CSS Variables for Consistency */
:root {
    --teal: rgba(0, 180, 204, 0.64);
    /* same as #00b4cca2 */
    --text-color: #333;
    --nav-bg: #333;
    --nav-link-color: #ffffff;
    --nav-link-hover-bg: #f0f0f0;
    --nav-link-hover-color: #2c2929;
    --button-bg: #007bff;
    --button-bg-hover: #0056b3;
    --btn-danger: #dc3545;
    --btn-success: #28a745;
    --font-family: 'Inter', Arial, sans-serif;
}

/* Reset and Base Typography */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family);
    color: var(--text-color);
    line-height: 1.6;
    background-color: #f8f9fa;
}

@media (max-width: 575.98px) {
    .compact-mobile-card .card-body,
    .card.compact-mobile-card .card-body {
        padding: .9rem !important;
    }

    .compact-mobile-title {
        font-size: 1rem !important;
        margin-bottom: .35rem !important;
    }

    .compact-mobile-copy {
        font-size: .82rem !important;
        margin-bottom: .55rem !important;
    }

    .compact-mobile-stack {
        gap: .55rem !important;
    }
}

/* Shared portal form system */
.portal-form {
    display: block;
}

.portal-form .form-label {
    font-size: .84rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: .38rem;
}

.portal-form input[type="text"],
.portal-form input[type="email"],
.portal-form input[type="password"],
.portal-form input[type="tel"],
.portal-form input[type="number"],
.portal-form input[type="date"],
.portal-form input[type="time"],
.portal-form input[type="file"],
.portal-form select,
.portal-form textarea {
    width: 100%;
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #fff;
    padding: .72rem .9rem;
    font-size: .95rem;
    color: #111827;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: border-color .15s ease, box-shadow .15s ease;
}

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

.portal-form input:focus,
.portal-form select:focus,
.portal-form textarea:focus {
    outline: 0;
    border-color: rgba(31, 95, 120, 0.55);
    box-shadow: 0 0 0 4px rgba(31, 95, 120, 0.12);
}

.portal-form .form-text,
.portal-form .portal-field-help {
    margin-top: .4rem;
    font-size: .78rem;
    color: #6b7280;
}

.portal-form .portal-form-section {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    background: rgba(255,255,255,0.72);
    padding: 1rem;
    margin-bottom: 1rem;
}

.portal-form .portal-form-section h2,
.portal-form .portal-form-section h3 {
    font-size: .92rem;
    font-weight: 700;
    margin-bottom: .85rem;
    color: #0f172a;
}

.portal-form .portal-form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.portal-form .form-check {
    padding-left: 1.85rem;
}

.portal-form .form-check-input {
    margin-top: .22rem;
}

.portal-form .portal-inline-summary {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    background: #f8fafc;
    padding: .95rem 1rem;
}

.upload-form-shell {
    max-width: 980px;
    margin: 0 auto;
}

.upload-hero-card,
.portal-form .upload-section {
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
}

.upload-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #1f5f78;
    background: rgba(31, 95, 120, 0.10);
    font-size: 1.35rem;
}

.upload-kicker {
    color: #1f5f78;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.upload-section-heading {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.portal-form .upload-section-heading h2 {
    margin: 0 0 .2rem;
}

.upload-section-heading p {
    margin: 0;
    color: #6b7280;
    font-size: .86rem;
}

.upload-step {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: #1f5f78;
    color: #fff;
    font-weight: 800;
    font-size: .85rem;
}

.upload-field-grid,
.upload-access-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.upload-field-wide {
    grid-column: 1 / -1;
}

.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    border: 1.5px dashed rgba(31, 95, 120, 0.30);
    border-radius: 20px;
    background: rgba(31, 95, 120, 0.04);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.upload-dropzone:hover {
    border-color: rgba(31, 95, 120, 0.55);
    background: rgba(31, 95, 120, 0.07);
}

.upload-dropzone-icon {
    color: #1f5f78;
    font-size: 1.45rem;
}

.upload-dropzone-title {
    color: #0f172a;
    font-weight: 800;
}

.upload-dropzone-copy {
    color: #6b7280;
    font-size: .82rem;
}

.upload-dropzone input[type="file"] {
    margin-top: .75rem;
    max-width: 520px;
}

.upload-publish-toggle {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    background: #f8fafc;
    padding: .95rem 1rem;
    display: flex;
    align-items: center;
}

.upload-actions {
    justify-content: flex-end;
}

@media (max-width: 575.98px) {
    .portal-form input[type="text"],
    .portal-form input[type="email"],
    .portal-form input[type="password"],
    .portal-form input[type="tel"],
    .portal-form input[type="number"],
    .portal-form input[type="date"],
    .portal-form input[type="time"],
    .portal-form input[type="file"],
    .portal-form select,
    .portal-form textarea {
        min-height: 42px;
        padding: .62rem .78rem;
        font-size: .88rem;
        border-radius: 12px;
    }

    .portal-form .form-label {
        font-size: .79rem;
        margin-bottom: .28rem;
    }

    .portal-form .portal-form-section {
        padding: .85rem;
        border-radius: 16px;
        margin-bottom: .85rem;
    }

    .portal-form .portal-form-actions {
        gap: .55rem;
    }

    .portal-form .portal-form-actions .btn {
        width: 100%;
    }

    .upload-form-shell {
        max-width: 100%;
    }

    .upload-icon {
        width: 44px;
        height: 44px;
        border-radius: 15px;
        font-size: 1.1rem;
    }

    .upload-field-grid,
    .upload-access-grid {
        grid-template-columns: 1fr;
        gap: .75rem;
    }

    .upload-section-heading {
        gap: .65rem;
        margin-bottom: .85rem;
    }

    .upload-section-heading p,
    .upload-dropzone-copy {
        font-size: .78rem;
    }

    .upload-dropzone {
        padding: 1rem .85rem;
        border-radius: 16px;
    }
}

/* Header Styling */
header {
    /* background-color: var(--teal) !important; */
    padding: 0px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    padding: 1em;
    max-height: 70px;
}

/* Version text */
.version {
    font-size: small;
    color: var(--text-color);
}

/* Legacy nav list styling removed.
   Bootstrap navbar/dropdown components drive navigation now.
   The old 14rem nav font rules caused massive menu rendering problems on mobile. */

/* Logout form alignment */
#logout-form {
    margin-left: 1em;
}

/* Buttons */
.button {
    display: inline-block;
    padding: 10px 20px;
    margin: 10px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    background-color: var(--button-bg);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button:hover {
    background-color: var(--button-bg-hover);
}

.button:active {
    background-color: var(--button-bg-hover);
    transform: translateY(1px);
}

.button-red {
    border: 3px solid var(--btn-danger) !important;
}

.button-green {
    border: 3px solid var(--btn-success) !important;
}

/* Main content styling */
main {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* Document list styling */
ul {
    list-style-type: none;
    width: 70%;
    padding: 0;
    margin: auto;
}

ul li {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1em;
}

ul li a {
    background-color: #adbccc;
    text-decoration: none;
    width: 100%;
    padding: 10px;
    border-radius: 5px;
}

.document-list a {
    color: var(--text-color);
    font-weight: 500;
    font-size: 1rem;
}

.dashboard {
    text-align: center;
    padding: 2em 1em;
}

.dashboard .intro {
    max-width: 600px;
    margin: 1em auto 2em;
    font-size: 1.1em;
    color: #555;
}

.dashboard-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2em;
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 250px;
    padding: 1.5em;
    text-decoration: none;
    color: inherit;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.dashboard-card i {
    font-size: 2.5em;
    color: #007bff;
    margin-bottom: 0.5em;
}

.dashboard-card h3 {
    margin-bottom: 0.3em;
    font-size: 1.3em;
}
/* Scorecard visual dashboards */
.visual-dashboard-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 1rem;
        overflow: visible;
    }
    .visual-dashboard-grid-four {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: start;
    }
    .dashboard-tile {
        border: 0;
        border-radius: 1rem;
        color: #fff;
        overflow: visible;
        min-height: 0;
        position: relative;
    }
    .department-drilldown {
        position: relative;
        z-index: 1;
    }
    .department-drilldown:hover,
    .department-drilldown:focus-within {
        z-index: 50;
    }
    .dashboard-tile-red { background: linear-gradient(135deg, #9f1239, #dc2626); }
    .dashboard-tile-amber { background: linear-gradient(135deg, #b45309, #f59e0b); color: #241605; }
    .dashboard-tile-green { background: linear-gradient(135deg, #065f46, #16a34a 62%, #22c55e); }
    .dashboard-tile-neutral { background: linear-gradient(135deg, #475569, #64748b); }
    .tile-health-meter {
        display: block;
        width: 100%;
        height: .55rem;
        overflow: hidden;
        appearance: none;
        -webkit-appearance: none;
        border: 0;
        border-radius: 999px;
        background: rgba(255,255,255,.22);
        box-shadow: inset 0 1px 2px rgba(15, 23, 42, .14);
    }
    .tile-health-meter::-webkit-progress-bar {
        background: rgba(255,255,255,.22);
        border-radius: inherit;
    }
    .tile-health-meter::-webkit-progress-value {
        min-width: .4rem;
        border-radius: inherit;
        background: rgba(255,255,255,.86);
    }
    .tile-health-meter::-moz-progress-bar {
        min-width: .4rem;
        border-radius: inherit;
        background: rgba(255,255,255,.86);
    }
    .tile-mini-facts {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: .45rem;
    }
    .tile-mini-facts > div {
        border-radius: .75rem;
        padding: .45rem .5rem;
        background: rgba(255,255,255,.14);
    }
    .tile-mini-facts > div > strong,
    .tile-mini-facts > div > span:not(.metric-popover) {
        display: block;
        line-height: 1.1;
    }
    .tile-mini-facts > div > span:not(.metric-popover) {
        margin-top: .16rem;
        font-size: .72rem;
        opacity: .8;
        text-transform: uppercase;
        letter-spacing: .02em;
    }
    .tile-fact-popover {
        cursor: help;
    }
    .tile-focus-line {
        min-height: 2.25rem;
        font-size: .82rem;
        line-height: 1.35;
    }
    .metric-pill {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 4.2rem;
        border-radius: 999px;
        padding: .45rem .7rem;
        font-weight: 700;
        background: rgba(255,255,255,.18);
        backdrop-filter: blur(2px);
    }
    .metric-pill-compact {
        min-width: auto;
        padding: .3rem .52rem;
        font-size: .84rem;
    }
    .metric-popover-trigger {
        position: relative;
        outline: 0;
    }
    .metric-popover-trigger:focus-visible {
        box-shadow: 0 0 0 3px rgba(255,255,255,.48);
    }
    .metric-popover {
        position: absolute;
        left: 0;
        top: calc(100% + .55rem);
        z-index: 100;
        display: none;
        width: min(21rem, 82vw);
        max-height: 18rem;
        overflow: auto;
        border: 1px solid rgba(255,255,255,.22);
        border-radius: .95rem;
        padding: .75rem;
        color: #f8fafc;
        background: rgba(15, 23, 42, .94);
        box-shadow: 0 18px 38px rgba(15, 23, 42, .36);
        backdrop-filter: blur(10px);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-.25rem) scale(.98);
        pointer-events: none;
        transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
        text-align: left;
    }
    .metric-popover::before {
        content: "";
        position: absolute;
        top: -.42rem;
        left: 1rem;
        width: .8rem;
        height: .8rem;
        transform: rotate(45deg);
        background: rgba(15, 23, 42, .94);
        border-left: 1px solid rgba(255,255,255,.18);
        border-top: 1px solid rgba(255,255,255,.18);
    }
    .metric-popover-trigger:hover > .metric-popover,
    .metric-popover-trigger:focus > .metric-popover,
    .metric-popover-trigger:focus-visible > .metric-popover {
        display: block;
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
    .metric-popover > strong {
        display: block;
        margin-bottom: .45rem;
        font-size: .82rem;
    }
    .metric-popover-row,
    .metric-popover-empty {
        display: block;
        border-radius: .65rem;
        padding: .42rem .5rem;
        background: rgba(255,255,255,.08);
    }
    .metric-popover-row + .metric-popover-row,
    .metric-popover-row + .metric-popover-empty,
    .metric-popover-empty + .metric-popover-empty {
        margin-top: .35rem;
    }
    .metric-popover-row b,
    .metric-popover-row small {
        display: block;
        line-height: 1.2;
    }
    .metric-popover-row b {
        font-size: .82rem;
    }
    .metric-popover-row small,
    .metric-popover-empty {
        margin-top: .12rem;
        color: rgba(248,250,252,.76);
        font-size: .72rem;
        font-weight: 600;
    }
    .metric-popover-red > strong { color: #fecdd3; }
    .metric-popover-amber > strong { color: #fde68a; }
    .metric-popover-green > strong { color: #bbf7d0; }
    .trend-popover-trigger {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        border-radius: 999px;
        background: rgba(255,255,255,.18);
        cursor: help;
        outline: 0;
    }
    .trend-popover-trigger:focus-visible {
        box-shadow: 0 0 0 3px rgba(255,255,255,.48);
    }
    .trend-popover {
        position: absolute;
        right: 0;
        top: calc(100% + .55rem);
        z-index: 110;
        display: none;
        width: min(23rem, 84vw);
        border: 1px solid rgba(255,255,255,.22);
        border-radius: 1rem;
        padding: .85rem;
        color: #f8fafc;
        background: rgba(15, 23, 42, .95);
        box-shadow: 0 20px 42px rgba(15, 23, 42, .38);
        backdrop-filter: blur(10px);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-.25rem) scale(.98);
        pointer-events: none;
        transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
        text-align: left;
    }
    .trend-popover::before {
        content: "";
        position: absolute;
        top: -.42rem;
        right: .7rem;
        width: .8rem;
        height: .8rem;
        transform: rotate(45deg);
        background: rgba(15, 23, 42, .95);
        border-left: 1px solid rgba(255,255,255,.18);
        border-top: 1px solid rgba(255,255,255,.18);
    }
    .trend-popover-trigger:hover > .trend-popover,
    .trend-popover-trigger:focus > .trend-popover,
    .trend-popover-trigger:focus-visible > .trend-popover {
        display: block;
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }
    .trend-popover > strong,
    .trend-popover-summary,
    .trend-popover-mix {
        display: block;
    }
    .trend-popover > strong {
        margin-bottom: .7rem;
        font-size: .9rem;
    }
    .trend-chart {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: end;
        gap: .55rem;
        height: 8rem;
        padding: .65rem .6rem .35rem;
        border-radius: .85rem;
        background: linear-gradient(to top, rgba(255,255,255,.08), rgba(255,255,255,.03));
    }
    .trend-chart-column {
        display: flex;
        min-width: 0;
        height: 100%;
        flex-direction: column;
        justify-content: end;
        align-items: center;
        gap: .28rem;
    }
    .trend-chart-bar {
        width: 100%;
        min-height: .25rem;
        border-radius: .45rem .45rem .18rem .18rem;
        background: linear-gradient(180deg, #fb7185, #f59e0b);
    }
    .trend-chart-bar-current {
        outline: 2px solid rgba(255,255,255,.7);
        outline-offset: 2px;
    }
    .trend-chart-column small {
        color: rgba(248,250,252,.82);
        font-size: .68rem;
        font-weight: 800;
    }
    .trend-chart-labels {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: .55rem;
        margin-top: .35rem;
    }
    .trend-chart-labels small {
        overflow: hidden;
        color: rgba(248,250,252,.66);
        font-size: .62rem;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .trend-chart-cols-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
    .trend-popover-summary {
        margin-top: .65rem;
        font-size: .78rem;
        font-weight: 700;
    }
    .trend-popover-mix {
        margin-top: .25rem;
        color: rgba(248,250,252,.72);
        font-size: .72rem;
        font-weight: 700;
    }
    .trend-bar-h-0 { height: 4%; }
    .trend-bar-h-10 { height: 10%; }
    .trend-bar-h-20 { height: 20%; }
    .trend-bar-h-30 { height: 30%; }
    .trend-bar-h-40 { height: 40%; }
    .trend-bar-h-50 { height: 50%; }
    .trend-bar-h-60 { height: 60%; }
    .trend-bar-h-70 { height: 70%; }
    .trend-bar-h-80 { height: 80%; }
    .trend-bar-h-90 { height: 90%; }
    .trend-bar-h-100 { height: 100%; }
    .metric-pill-light { background: rgba(255,255,255,.82); color: #111827; }
    .department-drilldown summary,
    .test-drilldown summary,
    .week-drilldown summary,
    .employee-result-card summary {
        cursor: pointer;
        list-style: none;
    }
    .department-drilldown summary::-webkit-details-marker,
    .test-drilldown summary::-webkit-details-marker,
    .week-drilldown summary::-webkit-details-marker,
    .employee-result-card summary::-webkit-details-marker { display: none; }
    .department-drilldown[open] {
        grid-column: 1 / -1;
    }
    .compact-department-summary {
        min-height: 210px;
    }
    .department-accordion-panel {
        border-top: 1px solid rgba(15, 23, 42, .12);
    }
    .department-tests-table th,
    .department-tests-table td {
        vertical-align: top;
    }
    .test-name-column {
        min-width: 240px;
    }
    .week-cell {
        min-width: 230px;
    }
    .week-summary {
        display: flex;
        flex-wrap: wrap;
        gap: .25rem;
        align-items: center;
    }
    .week-user-list {
        max-height: 520px;
        overflow: auto;
    }
    .employee-result-card {
        background: #fff;
    }
    .employee-answer-table {
        font-size: .84rem;
    }
    .trend-strip {
        display: grid;
        grid-template-columns: repeat(5, minmax(24px, 1fr));
        gap: .25rem;
    }
    .trend-cell {
        border-radius: .45rem;
        padding: .3rem .2rem;
        font-size: .78rem;
        font-weight: 700;
        text-align: center;
        background: rgba(255,255,255,.2);
    }
    .trend-cell.metric-popover-trigger {
        display: block;
        cursor: help;
    }
    .trend-cell .metric-popover {
        min-width: min(18rem, 82vw);
    }
    .answer-dot {
        width: .75rem;
        height: .75rem;
        display: inline-block;
        border-radius: 50%;
    }

@media (max-width: 1199.98px) {
    .visual-dashboard-grid-four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .visual-dashboard-grid-four {
        grid-template-columns: 1fr;
    }

    .compact-department-summary {
        min-height: 0;
    }

}
