#usp-rs-stage1{
    --usp-bg:#fff;
    --usp-panel:#fff;
    --usp-text:#142434;
    --usp-muted:#666;
    --usp-line:#e6e6e6;
    --usp-control-bg:#f5f5f5;
    --usp-control-border:#d5d5d5;
    --usp-control-text:#17342f;
    --usp-green:#207534;
    --usp-green-dark:#042420;
    --usp-selected-green:#08752f;
    --usp-selected-bg:rgba(8,117,47,0.08);

    position:relative;
    margin:20px 0;
    padding:18px 18px 0;
    border:1px solid var(--usp-line);
    border-radius:4px;
    background:var(--usp-bg);
    color:var(--usp-text);
    font-family:inherit;
    box-sizing:border-box;
}

#usp-rs-stage1 *,
#usp-rs-stage1 *::before,
#usp-rs-stage1 *::after{
    box-sizing:border-box;
}

/* Topbar and search */

#usp-rs-stage1 .usp-rs-topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    margin-bottom:20px;
}

/* Search presentation is defined centrally by the MSAL theme.
   These rules retain only Report Choices-specific layout behaviour. */

#usp-rs-stage1 .usp-rs-search-wrap{
    align-items:stretch;
    width:50%;
    min-width:320px;
    padding:0;
}

#usp-rs-stage1 .usp-rs-search::placeholder{
    color:var(--usp-muted);
}

#usp-rs-stage1 .usp-rs-search-clear,
#usp-rs-stage1 .usp-rs-search-icon{
    appearance:none;
}

#usp-rs-stage1 .usp-rs-top-actions{
    display:flex;
    align-items:center;
    gap:10px;
}

#usp-rs-stage1 .usp-rs-top-actions .msal-action-btn{
    width:auto;
    min-width:max-content;
    margin:0;
    padding-left:18px;
    padding-right:18px;
    white-space:nowrap;
}

#usp-rs-stage1 .usp-rs-order,
#usp-rs-stage1 .usp-rs-enquire{
    display:none;
}

#usp-rs-stage1 .usp-rs-order.usp-rs-visible,
#usp-rs-stage1 .usp-rs-enquire.usp-rs-visible{
    display:inline-flex;
    align-items:center;
    justify-content:center;
}


/* Report type tabs */

#usp-rs-stage1 .usp-rs-tabs{
    display:flex;
    gap:8px;
    align-items:flex-end;
    margin-bottom:0;
    background:transparent;
}

#usp-rs-stage1 .usp-rs-tab{
    appearance:none;
    flex:1 1 0;
    min-width:0;
    margin:0;
    padding:8px 13px;
    border:1px solid var(--usp-control-border);
    border-radius:5px;
    background:var(--usp-control-bg);
    color:var(--usp-control-text);
    font:inherit;
    font-size:14px;
    line-height:1.2;
    font-weight:600;
    text-align:center;
    cursor:pointer;
}

#usp-rs-stage1 .usp-rs-tab:hover,
#usp-rs-stage1 .usp-rs-tab:focus{
    border-color:var(--usp-green);
    color:var(--usp-green);
    outline:none;
}

#usp-rs-stage1 .usp-rs-tab[aria-selected="true"]{
    border-color:var(--usp-green);
    background:var(--usp-green);
    color:#fff;
}

#usp-rs-stage1 .usp-rs-tab[aria-selected="true"]:hover,
#usp-rs-stage1 .usp-rs-tab[aria-selected="true"]:focus{
    background:var(--usp-green-dark);
    border-color:var(--usp-green-dark);
    color:#fff;
}

/* Panel and A-Z controls */

#usp-rs-stage1 .usp-rs-panel{
    border:1px solid var(--usp-line);
    border-top:0;
    background:var(--usp-panel);
}

#usp-rs-stage1 .usp-rs-count{
    position:absolute;
    width:1px;
    height:1px;
    padding:0;
    margin:-1px;
    overflow:hidden;
    clip:rect(0 0 0 0);
    white-space:nowrap;
    border:0;
}

#usp-rs-stage1 .usp-rs-az{
    display:flex;
    flex-wrap:wrap;
    gap:4px;
    padding:9px 12px;
    border-bottom:1px solid var(--usp-line);
    background:#fff;
}

#usp-rs-stage1 .usp-rs-az-btn,
#usp-rs-stage1 .usp-rs-az-disabled{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:26px;
    height:26px;
    padding:0 6px;
    border:1px solid var(--usp-control-border);
    border-radius:3px;
    background:var(--usp-control-bg);
    color:var(--usp-control-text);
    font:inherit;
    font-size:12px;
    line-height:1;
}

#usp-rs-stage1 .usp-rs-az-btn{
    cursor:pointer;
}

#usp-rs-stage1 .usp-rs-az-btn:hover,
#usp-rs-stage1 .usp-rs-az-btn:focus{
    border-color:var(--usp-green);
    background:var(--usp-green);
    color:#fff;
    outline:none;
}

#usp-rs-stage1 .usp-rs-az-disabled{
    opacity:.45;
    cursor:default;
}

/* Report listing */

#usp-rs-stage1 .usp-rs-list{
    height:520px;
    overflow-y:auto;
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    grid-auto-rows:min-content;
    align-content:start;
    padding:8px 18px 12px;
    background:#fff;
    scroll-behavior:smooth;
}

#usp-rs-stage1 .usp-rs-row{
    display:flex;
    align-items:center;
    gap:7px;
    min-width:0;
    min-height:28px;
    padding:5px 10px 5px 4px;
    border:0;
    border-radius:3px;
    background:transparent;
    color:var(--usp-text);
}

#usp-rs-stage1 .usp-rs-title{
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    cursor:pointer;
}

#usp-rs-stage1 .usp-rs-info{
    appearance:none;
    flex:0 0 18px;
    width:18px;
    height:18px;
    padding:0;
    border:1px solid var(--usp-control-border);
    border-radius:50%;
    background:#fff;
    color:var(--usp-control-text);
    font:inherit;
    font-size:12px;
    font-weight:700;
    line-height:16px;
    text-align:center;
    cursor:pointer;
}

#usp-rs-stage1 .usp-rs-info:hover,
#usp-rs-stage1 .usp-rs-info:focus{
    border-color:var(--usp-green);
    color:var(--usp-green);
    outline:none;
}

/* Selected report: highlight both row and information control */

#usp-rs-stage1 .usp-rs-row:has(.usp-rs-info[aria-pressed="true"]){
    background:var(--usp-selected-bg);
    color:var(--usp-selected-green);
    font-weight:600;
}

#usp-rs-stage1 .usp-rs-info[aria-pressed="true"]{
    border-color:var(--usp-green);
    background:var(--usp-green);
    color:#fff;
}

#usp-rs-stage1 .usp-rs-info[aria-pressed="true"]:hover,
#usp-rs-stage1 .usp-rs-info[aria-pressed="true"]:focus{
    border-color:var(--usp-green-dark);
    background:var(--usp-green-dark);
    color:#fff;
}

/* Selection actions */

#usp-rs-stage1 .usp-rs-clear-selections{
    appearance:none;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:38px;
    height:38px;
    padding:0;
    border:1px solid var(--usp-control-border);
    border-radius:4px;
    background:var(--usp-control-bg);
    color:var(--usp-control-text);
    font:inherit;
    font-size:24px;
    line-height:1;
    cursor:pointer;
}

#usp-rs-stage1 .usp-rs-clear-selections:hover,
#usp-rs-stage1 .usp-rs-clear-selections:focus{
    border-color:var(--usp-green);
    background:var(--usp-green);
    color:#fff;
    outline:none;
}

/* Footer and selected-report view */

#usp-rs-stage1 .usp-rs-footer{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    min-height:44px;
    padding:10px 12px;
    border-top:1px solid var(--usp-line);
    background:#fff;
    color:var(--usp-muted);
    font-size:13px;
}

#usp-rs-stage1 .usp-rs-footer-note{
    min-width:0;
}

#usp-rs-stage1 .usp-rs-select-view{
    appearance:none;
    border:0;
    padding:2px 0;
    background:transparent;
    color:var(--usp-green);
    font:inherit;
    font-weight:600;
    text-decoration:none;
    cursor:pointer;
}

#usp-rs-stage1 .usp-rs-select-view:hover,
#usp-rs-stage1 .usp-rs-select-view:focus{
    color:var(--usp-green-dark);
    text-decoration:underline;
    outline:none;
}

#usp-rs-stage1 [hidden]{
    display:none !important;
}

/* Report information popup */

#usp-rs-stage1 .usp-rs-popup{
    position:absolute;
    z-index:1000;
    display:none;
    width:min(260px,calc(100% - 20px));
    padding:10px 12px;
    border:1px solid #d6dce0;
    border-radius:3px;
    background:#fff;
    color:#555;
    box-shadow:0 2px 7px rgba(0,0,0,.16);
    pointer-events:none;
}

#usp-rs-stage1 .usp-rs-popup[aria-hidden="false"]{
    display:block;
}

#usp-rs-stage1 .usp-rs-popup-row{
    display:flex;
    justify-content:flex-start;
    gap:8px;
    line-height:1.45;
}

#usp-rs-stage1 .usp-rs-popup-label{
    color:#555;
}

#usp-rs-stage1 .usp-rs-popup-value{
    flex:0 0 34px;
    color:#555;
    font-weight:400;
    text-align:right;
}

#usp-rs-stage1 .usp-rs-popup-loading{
    color:#555;
    font-style:italic;
}

/* Loading state */

@keyframes usp-rs-spin{
    from{transform:rotate(0deg);}
    to{transform:rotate(360deg);}
}

#usp-rs-stage1 .usp-rs-clear-selections.usp-rs-loading{
    animation:usp-rs-spin .7s linear infinite;
    transform-origin:50% 50%;
}

#usp-rs-stage1 .usp-rs-clear-selections[aria-busy="true"]{
    cursor:progress;
}

/* Search-engine title index */

#usp-rs-stage1 .usp-rs-seo-title-index{
    position:absolute !important;
    left:-10000px !important;
    top:auto !important;
    width:1px !important;
    height:1px !important;
    overflow:hidden !important;
    white-space:normal !important;
}

/* Responsive layout */

@media (max-width:1100px){
    #usp-rs-stage1 .usp-rs-topbar{
        flex-direction:column;
        align-items:stretch;
        gap:12px;
    }

    #usp-rs-stage1 .usp-rs-search-wrap{
        width:100%;
        max-width:none;
        min-width:0;
    }

    #usp-rs-stage1 .usp-rs-top-actions{
        justify-content:flex-end;
    }

    #usp-rs-stage1 .usp-rs-list{
        grid-template-columns:repeat(2,minmax(0,1fr));
    }
}

@media (max-width:640px){
    #usp-rs-stage1{
        padding:12px 12px 0;
    }

    #usp-rs-stage1 .usp-rs-topbar{
        flex-direction:column;
        align-items:stretch;
        gap:10px;
        margin-bottom:14px;
    }

    #usp-rs-stage1 .usp-rs-search-wrap{
        width:100%;
        max-width:none;
        min-width:0;
    }

    #usp-rs-stage1 .usp-rs-top-actions{
        justify-content:flex-end;
    }

    #usp-rs-stage1 .usp-rs-top-actions .msal-action-btn{
        flex:1 1 0;
        min-width:0;
        padding-left:8px;
        padding-right:8px;
    }

    #usp-rs-stage1 .usp-rs-tabs{
        gap:5px;
    }

    #usp-rs-stage1 .usp-rs-tab{
        padding:9px 8px;
    }

    #usp-rs-stage1 .usp-rs-list{
        height:480px;
        grid-template-columns:1fr;
        padding:8px 10px 12px;
    }

    #usp-rs-stage1 .usp-rs-footer{
        flex-direction:column;
        align-items:flex-start;
        gap:6px;
    }
}

/* MSAL visual refinements */

#usp-rs-stage1 .usp-rs-tabs{
    justify-content:flex-start;
}

#usp-rs-stage1 .usp-rs-tab{
    flex:0 0 auto;
    min-width:auto;
    padding:8px 13px;
}

#usp-rs-stage1 .usp-rs-title{
    font-size:14px;
    line-height:1.25;
}

#usp-rs-stage1 .usp-rs-info{
    border-color:#666;
    background:#666;
    color:#fff;
}

@media (max-width:780px){
    #usp-rs-stage1 .usp-rs-list{
        grid-template-columns:1fr;
    }
}
