/* ── App shell ──────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 268px;
    flex-shrink: 0;
    background:
        radial-gradient(circle at 110% -10%, rgba(226, 208, 0, 0.18), transparent 40%),
        linear-gradient(180deg, var(--brand-purple) 0%, var(--brand-purple-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.25rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.65rem;
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.sidebar-brand-name {
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: 1rem;
}

.sidebar-brand-tagline {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.75rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.nav-group + .nav-group {
    margin-top: 0.35rem;
}

.nav-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: none;
    border: none;
    padding: 0.55rem 0.6rem 0.35rem;
    color: var(--brand-gold);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    opacity: 0.9;
}

.nav-group-header:hover {
    opacity: 1;
}

.nav-group-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}

.nav-group-collapsed .nav-group-chevron {
    transform: rotate(-90deg);
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.82);
    padding: 0.55rem 0.75rem;
    margin: 0.1rem 0;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border-radius: 0.5rem;
    font-size: 0.92rem;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link .bi {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.9;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-link.active .bi {
    color: var(--brand-gold);
    opacity: 1;
}

.sidebar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 0.4rem;
    bottom: 0.4rem;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--brand-gold);
}

.sidebar-footer {
    padding: 0.85rem 1.25rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer .bi {
    color: var(--brand-gold);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 0 rgba(226, 208, 0, 0.35);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-context {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.topbar-context .bi {
    color: var(--brand-purple);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--brand-purple);
    padding: 0;
}

.content {
    flex: 1;
    padding: 1.5rem;
    background: var(--page-bg);
}

.sidebar-backdrop {
    display: none;
}

/* Topbar dropdowns are native <details> so they also work on statically rendered pages. */
.topbar-menu {
    position: relative;
}

.topbar-menu > summary {
    list-style: none;
    cursor: pointer;
}

.topbar-menu > summary::-webkit-details-marker {
    display: none;
}

.topbar-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--brand-purple-soft);
    color: var(--brand-purple);
    font-size: 1.15rem;
    transition: background 0.15s ease;
}

.topbar-icon-btn:hover,
.topbar-menu[open] > .topbar-icon-btn {
    background: var(--brand-purple-tint);
}

.notif-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
    border: 2px solid #fff;
    font-size: 0.66rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.6rem);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.85rem;
    box-shadow: 0 18px 40px rgba(61, 9, 69, 0.18);
    z-index: 1060;
    overflow: hidden;
    animation: dropdown-in 0.14s ease-out;
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.notif-panel {
    width: min(380px, calc(100vw - 2rem));
}

.notif-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-mid));
    color: #fff;
    border-bottom: 3px solid var(--brand-gold);
}

.notif-panel-header .btn-link {
    color: var(--brand-gold);
    text-decoration: none;
    font-weight: 600;
}

.notif-panel-title {
    font-weight: 700;
}

.notif-panel-sub {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
}

.notif-panel-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.notif-item:hover {
    background: var(--neutral-100);
    color: var(--text-primary);
}

.notif-item.unread {
    background: var(--brand-gold-soft);
}

.notif-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--brand-purple-soft);
    color: var(--brand-purple);
}

.notif-icon-announcement { background: var(--brand-gold); color: var(--brand-purple-dark); }
.notif-icon-submission { background: #dcfce7; color: var(--stat-green); }
.notif-icon-research { background: var(--brand-purple); color: var(--brand-gold); }
.notif-icon-account { background: #e0f2fe; color: #0369a1; }

.notif-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.notif-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.notif-message {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.notif-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--brand-purple);
    margin-top: 0.4rem;
    flex-shrink: 0;
}

.notif-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.notif-empty .bi {
    font-size: 2rem;
    color: var(--brand-purple-tint);
}

.notif-panel-footer {
    display: block;
    text-align: center;
    padding: 0.7rem;
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    background: var(--neutral-100);
}

.notif-toast {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1080;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    width: min(360px, calc(100vw - 2rem));
    padding: 0.9rem 1rem;
    background: #fff;
    border-radius: 0.75rem;
    border-left: 5px solid var(--brand-gold);
    box-shadow: 0 18px 40px rgba(61, 9, 69, 0.22);
    animation: dropdown-in 0.2s ease-out;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.25rem 0.6rem 0.25rem 0.25rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-primary);
}

.user-chip:hover,
.topbar-menu[open] > .user-chip {
    border-color: var(--brand-purple-tint);
    background: var(--brand-purple-soft);
}

.user-chip > .bi {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-mid));
    color: var(--brand-gold);
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
}

.user-avatar-lg {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1rem;
}

.user-chip-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    text-align: left;
}

.user-chip-name {
    font-weight: 600;
    font-size: 0.86rem;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip-role {
    font-size: 0.72rem;
    color: var(--brand-purple);
}

.user-menu-panel {
    width: 270px;
    padding-bottom: 0.4rem;
}

.user-menu-header {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.min-w-0 {
    min-width: 0;
}

.user-menu-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--brand-purple-soft);
    color: var(--brand-purple);
    border: 1px solid var(--brand-purple-tint);
}

.role-pill-gold {
    background: var(--brand-gold-soft);
    color: #6b5f00;
    border-color: #efe38a;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.55rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    background: none;
    border: none;
    font-size: 0.9rem;
    text-align: left;
}

.user-menu-item .bi {
    color: var(--brand-purple);
}

.user-menu-item:hover {
    background: var(--brand-purple-soft);
    color: var(--brand-purple-dark);
}

.user-menu-logout {
    border-top: 1px solid var(--border-color);
    margin-top: 0.3rem;
    padding-top: 0.3rem;
}

.user-menu-logout .user-menu-item .bi {
    color: var(--danger);
}

/* Admin broadcast pinned above page content until dismissed */
.announcement-banner {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.1rem;
    margin-bottom: 1rem;
    border-radius: 0.75rem;
    background: linear-gradient(90deg, var(--brand-purple-dark), var(--brand-purple));
    color: #fff;
    border-left: 6px solid var(--brand-gold);
    box-shadow: 0 6px 18px rgba(61, 9, 69, 0.18);
}

.announcement-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.announcement-text {
    flex: 1;
    min-width: 0;
}

.announcement-title {
    font-weight: 700;
}

.announcement-message {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.85);
}

.announcement-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    /* The sidebar becomes an off-canvas panel instead of stacking above the content — a
       respondent filling out a form on a phone needs the full screen width, not the sidebar
       eating vertical space above it. */
    .app-shell {
        position: relative;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(290px, 82vw);
        height: 100%;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: inline-block;
    }

    .sidebar-backdrop.sidebar-open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1040;
    }

    .topbar {
        padding: 0.5rem 0.75rem;
    }

    .topbar-context,
    .user-chip-text {
        display: none;
    }

    .content {
        padding: 0.75rem;
    }

    .announcement-banner {
        flex-wrap: wrap;
    }

    .announcement-time {
        display: none;
    }
}

/* ── Account pages (sign in / password reset) ─────────────────────────────── */
.auth-shell {
    display: flex;
    min-height: 100vh;
    background: #fff;
}

.auth-hero {
    position: relative;
    flex: 1;
    overflow: hidden;
    color: #fff;
    padding: 3rem 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background:
        linear-gradient(140deg, #2a0530 0%, var(--brand-purple) 45%, var(--brand-purple-mid) 100%);
}

/* Research motif artwork (charts, survey sheet, map pins, data network) layered behind the copy */
.auth-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("../images/research-pattern.svg") right bottom / cover no-repeat;
    opacity: 0.35;
    pointer-events: none;
}

.auth-hero > * {
    position: relative;
    z-index: 1;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.auth-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.85rem;
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
    font-size: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.auth-brand-name {
    font-weight: 800;
    letter-spacing: 0.06em;
    font-size: 1.2rem;
}

.auth-hero-copy {
    max-width: 560px;
    /* Centre the copy in the space below the logo, nudged slightly above true centre */
    margin: auto 0;
    padding-bottom: 4rem;
}

.auth-hero-copy::after {
    content: "";
    display: block;
    width: 3.5rem;
    height: 4px;
    margin-top: 1.5rem;
    border-radius: 2px;
    background: var(--brand-gold);
}

.auth-hero h1 {
    font-size: clamp(1.9rem, 3vw, 2.7rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
}

.auth-hero h1 .text-gold {
    color: var(--brand-gold);
}

.auth-hero-lead {
    color: rgba(255, 255, 255, 0.78);
    font-size: 1.02rem;
    margin-bottom: 0;
}

.auth-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background:
        radial-gradient(circle at 100% 0%, var(--brand-gold-soft), transparent 35%),
        var(--page-bg);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 1.1rem;
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--brand-purple);
    box-shadow: 0 24px 60px rgba(61, 9, 69, 0.12);
    padding: 2.25rem 2rem;
}

/* Identity's stock account pages lay forms out in .col-md-4 — inside this card that would
   shrink them to a third of its width, so let every column fill the card instead. */
.auth-card .row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-purple);
}

.auth-card h2 {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-muted);
}

.auth-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.9rem;
    background: var(--brand-purple-soft);
    color: var(--brand-purple);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--brand-purple-tint);
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.auth-field {
    margin-bottom: 1rem;
}

.auth-field label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.auth-input {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--border-color);
    border-radius: 0.65rem;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
}

.auth-input:focus-within {
    border-color: var(--brand-purple);
    box-shadow: 0 0 0 0.2rem rgba(226, 208, 0, 0.35);
}

.auth-input-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.9rem;
    color: var(--brand-purple);
    background: var(--brand-purple-soft);
    border-right: 1px solid var(--border-color);
    font-size: 1.05rem;
}

.auth-input .form-control {
    border: none;
    border-radius: 0;
    padding: 0.7rem 0.85rem;
    box-shadow: none !important;
    outline: none !important;
}

.auth-input-toggle {
    border: none;
    background: none;
    padding: 0 0.85rem;
    color: var(--text-muted);
}

.auth-input-toggle:hover {
    color: var(--brand-purple);
}

.auth-submit {
    width: 100%;
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-mid)) !important;
    border: none !important;
    border-bottom: 3px solid var(--brand-gold) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.auth-submit:hover {
    box-shadow: 0 10px 24px rgba(87, 13, 97, 0.3);
    transform: translateY(-1px);
}

.auth-links {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    font-size: 0.86rem;
}

.auth-links a {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

@media (max-width: 359.98px) {
    .auth-links {
        flex-wrap: wrap;
    }
}

.auth-links-sep {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brand-gold-dark);
}

.auth-hint {
    margin: 1.25rem 0 0;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-panel-footer {
    margin-top: 1.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

@media (max-width: 991.98px) {
    .auth-shell {
        flex-direction: column;
    }

    .auth-hero {
        flex: none;
        padding: 1.75rem 1.5rem 2.75rem;
        gap: 1.25rem;
    }

    .auth-hero h1 {
        font-size: 1.6rem;
    }

    .auth-hero-copy {
        margin: 0;
        padding-bottom: 0;
    }

    .auth-hero-copy::after {
        display: none;
    }

    .auth-hero-lead {
        display: none;
    }

    .auth-panel {
        padding: 1.5rem 1rem 2rem;
        margin-top: -1.25rem;
        border-radius: 1.25rem 1.25rem 0 0;
        position: relative;
        z-index: 2;
        justify-content: flex-start;
    }

    .auth-card {
        padding: 1.75rem 1.25rem;
    }
}

/* Data-entry respondent view — a single centered card, closer to a Google-Forms-style form */
.submit-form-card {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 2rem;
}

/* One question per card, left accent bar, generous spacing — used by DynamicQuestionInput */
.question-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--brand-purple);
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
}

.question-card .form-label {
    font-size: 1.05rem;
}

.question-card-missing {
    border-left-color: var(--danger);
    background: #fff5f5;
}

.question-number {
    color: var(--brand-purple);
    font-weight: 700;
    margin-right: 0.15rem;
}

@media (max-width: 767.98px) {
    /* "occupy the whole space" on a phone — drop the card chrome/padding that made sense on
       desktop but just wastes width on a small screen. */
    .submit-form-card {
        max-width: 100%;
        padding: 0.75rem;
        border: none;
        border-radius: 0;
    }

    .question-card {
        padding: 0.85rem 1rem;
    }
}

/* Builder: question rows + drag handles */
.section-questions {
    /* An empty section must still be a valid, visible drop target for SortableJS (and for a
       real user's eye) — with no children and no min-height, it collapses to zero height and
       nothing can ever be dropped into it. */
    min-height: 3rem;
}

.question-row {
    background: #fff;
    transition: box-shadow 0.15s ease;
}

.question-row:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.drag-handle {
    cursor: grab;
}

.section-questions.sortable-ghost {
    opacity: 0.4;
}

/* Google-Forms-style "add question" flyout */
.question-type-menu {
    min-width: 260px;
    max-height: 420px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.question-type-menu .dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding-top: 0.5rem;
}

.question-type-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 1rem;
}

.question-type-item .bi {
    width: 1.25rem;
    text-align: center;
    color: var(--brand-purple);
}

.question-type-item:hover {
    background: var(--neutral-100);
}

/* Zebra-striped tables used across admin/report pages */
.table-hover tbody tr:hover {
    background-color: var(--neutral-100);
}

/* PageHeader — used at the top of every page instead of a plain <h1>. Two variants:
   "Gradient" (default, purple brand bar) for respondent/welcome pages, and "Light" (white
   panel + colored icon avatar, matching USAWAv2's dashboard reference) for admin/list pages. */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.page-header-gradient {
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-mid));
    color: #fff;
    border-bottom: 3px solid var(--brand-gold);
}

.page-header-light {
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--brand-purple);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

/* Thin gold accent along the bottom of light headers — the "mix of gold" against the purple. */
.page-header-light::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 120px;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-gold), transparent);
}

.page-header-text {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.page-header-icon-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.page-header-gradient .page-header-icon-avatar {
    background: rgba(255, 255, 255, 0.15);
    color: var(--brand-gold);
}

.page-header-light .page-header-icon-avatar {
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-mid));
    color: var(--brand-gold);
    box-shadow: 0 4px 10px rgba(87, 13, 97, 0.25);
}

/* Logos come in any shape — fit the whole image inside a white tile rather than cropping it
   to a circle, so wide wordmarks and square crests both stay fully visible. */
.page-header-logo {
    width: 3.25rem;
    height: 3.25rem;
    padding: 0.3rem;
    border-radius: 0.75rem;
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.page-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.page-header-gradient .page-header-title {
    color: #fff;
}

.page-header-light .page-header-title {
    color: var(--brand-purple);
}

.page-header-subtitle {
    font-size: 0.9rem;
}

.page-header-gradient .page-header-subtitle {
    color: rgba(255, 255, 255, 0.85);
}

.page-header-light .page-header-subtitle {
    color: var(--text-muted);
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* CenterLogo variant (respondent submission page): logo stacked above a centered title
   instead of the default logo-beside-title row. */
.page-header-centered {
    flex-direction: column;
    text-align: center;
}

.page-header-centered .page-header-text {
    flex-direction: column;
    text-align: center;
}

.page-header-centered .page-header-logo {
    width: auto;
    max-width: min(16rem, 80%);
    height: 5.5rem;
    padding: 0.5rem 0.85rem;
    margin-bottom: 0.25rem;
}

.page-header-light .page-header-actions .btn-light {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Collapsible panels — grouping content (e.g. a dashboard section's charts/filters) under a
   toggleable header, matching the reference dashboard's "Data Filters" / "Reviews Trend" panels */
.collapsible-panel {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.collapsible-panel-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
}

.collapsible-panel-icon-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--brand-purple);
    color: var(--brand-gold);
    flex-shrink: 0;
}

.collapsible-panel-text {
    flex: 1;
    min-width: 0;
}

.collapsible-panel-title {
    font-weight: 700;
    color: var(--text-primary);
}

.collapsible-panel-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.collapsible-panel-chevron {
    color: var(--text-muted);
}

.collapsible-panel-body {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

@media (max-width: 767.98px) {
    .page-header {
        padding: 1rem;
    }

    .page-header-title {
        font-size: 1.2rem;
    }
}

/* Section header bar — clearly demarcates a section's title + explanation from its questions,
   both in the builder and in the data-entry/preview render */
.section-header-bar {
    background: var(--neutral-100);
    border-left: 4px solid var(--brand-purple);
    border-radius: 0.375rem 0.375rem 0 0;
    padding: 0.85rem 1.25rem;
}

.section-header-title {
    color: var(--brand-purple);
    font-weight: 700;
}

.section-header-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    margin-bottom: 0;
}

/* ── Admin building blocks (Users & Access, Menu Permissions, Notifications) ── */
.text-brand { color: var(--brand-purple); }
.text-gold-dark { color: var(--brand-gold-dark); }

.admin-panel {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.85rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fff, var(--neutral-100));
}

.admin-search {
    position: relative;
    flex: 1 1 260px;
    max-width: 420px;
}

.admin-search > .bi {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--brand-purple);
    pointer-events: none;
}

.admin-search .form-control {
    padding-left: 2.4rem;
    border-radius: 999px;
}

.admin-filter {
    width: auto;
    min-width: 150px;
    border-radius: 999px;
}

.admin-toolbar-count {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.admin-table > tbody > tr > td {
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
}

.admin-table td:first-child,
.admin-table th:first-child {
    padding-left: 1.25rem;
}

.admin-table td:last-child,
.admin-table th:last-child {
    padding-right: 1.25rem;
}

.row-disabled td {
    opacity: 0.6;
}

.row-disabled td:last-child {
    opacity: 1;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}

.status-chip-on { background: #dcfce7; color: #15803d; }
.status-chip-off { background: #fee2e2; color: #b91c1c; }

.btn-icon {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    color: var(--brand-purple);
    background: transparent;
    border: 1px solid transparent;
}

.btn-icon:hover {
    background: var(--brand-purple-soft);
    border-color: var(--brand-purple-tint);
}

.btn-icon:disabled {
    opacity: 0.35;
}

.staff-results {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 5;
    margin-top: 0.3rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.65rem;
    box-shadow: 0 12px 30px rgba(61, 9, 69, 0.15);
    max-height: 260px;
    overflow-y: auto;
}

.staff-result {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: none;
    background: none;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.staff-result:hover {
    background: var(--brand-gold-soft);
}

.staff-result > .bi {
    color: var(--brand-purple);
    margin-top: 0.15rem;
}

.role-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.6rem;
}

.role-option {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    padding: 0.75rem 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: 0.7rem;
    background: #fff;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.role-option > .bi {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.role-option strong {
    display: block;
    font-size: 0.9rem;
}

.role-option small {
    color: var(--text-muted);
    font-size: 0.76rem;
}

.role-option:hover {
    border-color: var(--brand-purple-tint);
}

.role-option.selected {
    border-color: var(--brand-purple);
    background: var(--brand-purple-soft);
    box-shadow: inset 0 -3px 0 var(--brand-gold);
}

.role-option.selected > .bi {
    color: var(--brand-purple);
}

.sms-option {
    padding: 0.85rem 1rem;
    border-radius: 0.7rem;
    background: var(--brand-gold-soft);
    border: 1px solid #efe38a;
}

.sms-option .form-check-input {
    margin-top: 0.3rem;
}

.sms-option label .bi {
    color: var(--brand-purple);
}

.credential-box {
    border: 1px dashed var(--brand-purple-tint);
    border-radius: 0.7rem;
    background: var(--brand-purple-soft);
    padding: 0.4rem 1rem;
}

.credential-box > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0;
}

.credential-box > div + div {
    border-top: 1px solid var(--brand-purple-tint);
}

.credential-box span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.credential-box strong {
    color: var(--brand-purple-dark);
    word-break: break-all;
    text-align: right;
}

.unsaved-bar {
    position: sticky;
    top: 4rem;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.7rem;
    background: var(--brand-purple);
    color: #fff;
    box-shadow: 0 8px 20px rgba(61, 9, 69, 0.2);
}

.unsaved-bar > span {
    flex: 1;
}

.unsaved-bar > .bi {
    color: var(--brand-gold);
}

.perm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.perm-matrix th.perm-item-col {
    min-width: 280px;
    padding-left: 1.25rem;
}

.perm-matrix th.perm-role-col {
    min-width: 130px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.85rem;
}

.perm-matrix th.perm-role-col .bi {
    color: var(--brand-gold-dark);
    font-size: 1.1rem;
}

.perm-matrix td:first-child {
    padding-left: 1.25rem;
}

.perm-group-row td {
    background: linear-gradient(90deg, var(--brand-purple-soft), #fff);
    color: var(--brand-purple);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-top: 2px solid var(--brand-purple-tint);
}

.perm-group-row td .bi {
    color: var(--brand-gold-dark);
    margin-right: 0.3rem;
}

.perm-group-toggle {
    font-size: 0.72rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--brand-purple-tint);
    color: var(--brand-purple);
    background: #fff;
    text-transform: none;
    letter-spacing: 0;
}

.perm-group-toggle:hover {
    background: var(--brand-gold);
    border-color: var(--brand-gold);
}

.perm-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.6rem;
    background: var(--brand-purple-soft);
    color: var(--brand-purple);
    flex-shrink: 0;
}

.perm-switch {
    width: 2.6em !important;
    height: 1.35em;
    cursor: pointer;
}

.perm-locked {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--brand-gold-soft);
    color: var(--brand-gold-dark);
}

.perm-default {
    font-size: 0.65rem;
    color: var(--brand-gold-dark);
}

.perm-changed {
    background: var(--brand-gold-soft) !important;
    box-shadow: inset 0 0 0 2px var(--brand-gold);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.filter-chip > span {
    background: var(--neutral-100);
    border-radius: 999px;
    padding: 0 0.45rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.filter-chip.active {
    background: var(--brand-purple);
    border-color: var(--brand-purple);
    color: #fff;
}

.filter-chip.active > span {
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
}

.notif-row {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.notif-row.unread {
    background: var(--brand-gold-soft);
    box-shadow: inset 4px 0 0 var(--brand-gold);
}

.notif-message-full {
    -webkit-line-clamp: unset;
    display: block;
}

.notif-row-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .admin-search {
        max-width: none;
    }

    .admin-toolbar-count {
        margin-left: 0;
    }

    .notif-row {
        flex-wrap: wrap;
    }

    .notif-row-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ── Home: "How to complete a survey" stepper ─────────────────────────────── */
.survey-steps {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    list-style: none;
    margin: 0;
    padding: 0.25rem 0 0;
}

.survey-step {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 0.5rem;
}

/* Connector line running from this step's marker to the next one */
.survey-step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 1.15rem;
    left: calc(50% + 1.4rem);
    right: calc(-50% + 1.4rem);
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--brand-purple-tint) 0 6px, transparent 6px 10px);
}

.survey-step-marker {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.survey-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    background: var(--brand-purple);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 0 0 4px var(--brand-purple-soft);
}

.survey-step-final .survey-step-num {
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
    box-shadow: 0 0 0 4px var(--brand-gold-soft);
}

.survey-step-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.survey-step-icon {
    color: var(--brand-purple-mid);
    font-size: 1.15rem;
}

.survey-step-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.survey-step-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.35;
}

@media (max-width: 767.98px) {
    .survey-steps {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .survey-step {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
        gap: 0.85rem;
        padding: 0 0 1.1rem;
    }

    .survey-step:last-child {
        padding-bottom: 0;
    }

    /* Vertical connector on narrow screens */
    .survey-step:not(:last-child)::after {
        top: 2.6rem;
        bottom: 0.3rem;
        left: 1.1rem;
        right: auto;
        width: 2px;
        height: auto;
        background: repeating-linear-gradient(180deg, var(--brand-purple-tint) 0 6px, transparent 6px 10px);
    }

    .survey-step-marker {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .survey-step-body {
        align-items: flex-start;
        padding-top: 0.15rem;
    }

    .survey-step-icon {
        display: none;
    }
}

/* ── Home: open questionnaires list ──────────────────────────────────────── */
.open-survey-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.open-survey-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: #fff;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.open-survey-item:hover {
    border-color: var(--brand-purple-tint);
    box-shadow: 0 8px 20px rgba(61, 9, 69, 0.08);
    transform: translateY(-1px);
}

.open-survey-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.6rem;
    background: var(--brand-purple-soft);
    color: var(--brand-purple);
    flex-shrink: 0;
}

.open-survey-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.open-survey-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.open-survey-cta {
    flex-shrink: 0;
    white-space: nowrap;
}

.open-survey-empty {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-muted);
}

.open-survey-empty .bi {
    font-size: 1.4rem;
    color: #198754;
}

/* ── Public (shared-link) questionnaire layout — no sidebar or menus ─────── */
.public-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--page-bg);
}

.public-topbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.public-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.55rem;
    background: var(--brand-gold);
    color: var(--brand-purple-dark);
}

.public-brand-name {
    font-weight: 800;
    letter-spacing: 0.06em;
    font-size: 0.95rem;
    color: var(--brand-purple);
}

.public-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
}

.public-footer {
    padding: 1rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.public-message {
    max-width: 480px;
    margin: 3rem auto;
    padding: 2.5rem 2rem;
    text-align: center;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
}

.public-message > .bi {
    font-size: 2.75rem;
    color: var(--brand-purple);
}

.public-message h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0.75rem 0 0.5rem;
    color: var(--text-primary);
}

.public-message p {
    color: var(--text-muted);
    margin: 0;
}

@media (max-width: 767.98px) {
    .public-content {
        padding: 1rem 0.75rem 1.5rem;
    }

    .public-content .submit-form-card {
        padding: 1.25rem 1rem;
    }
}

/* ── Reports: numeric summary chips (dashboard Average/Min/Max over a range table) ── */
.numeric-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.numeric-chip {
    display: flex;
    flex-direction: column;
    min-width: 6.5rem;
    padding: 0.45rem 0.8rem;
    border-radius: 0.6rem;
    background: var(--brand-purple-soft);
    border: 1px solid var(--brand-purple-tint);
}

.numeric-chip span {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.numeric-chip strong {
    font-size: 1.05rem;
    color: var(--brand-purple-dark);
}

/* ── Analytics: AI-written narrative, styled like a report excerpt ───────── */
.ai-narrative {
    border: 1px solid var(--brand-purple-tint);
    border-left: 5px solid var(--brand-gold);
    border-radius: 0.75rem;
    background: #fff;
    padding: 1.25rem 1.5rem;
}

.ai-narrative-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-gold-dark);
    margin-bottom: 0.5rem;
}

.ai-narrative-body {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.ai-narrative-body h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand-purple);
    margin-bottom: 0.5rem;
}

.ai-narrative-body p:last-child {
    margin-bottom: 0;
}

.ai-narrative-body .ai-caption {
    font-style: italic;
    color: var(--brand-purple-mid);
}

/* ── AI findings report (all questions) ─────────────────────────────────── */
.ai-report-section {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-purple-dark);
    border-bottom: 2px solid var(--brand-purple-tint);
    padding-bottom: 0.35rem;
    margin: 2rem 0 1rem;
}

.ai-report-item {
    padding-left: 0.25rem;
}

/* Long question prompts in the analytics question picker */
.question-picker select {
    text-overflow: ellipsis;
}
