:root {
    --ink: #081020;
    --slate: #4c5968;
    --paper: #f4f6f8;
    --line: rgba(8, 16, 32, 0.12);
    --ease: cubic-bezier(0.22, 0.8, 0.28, 1);
    --inline: max(1.25rem, calc((100vw - 1120px) / 2));
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scrollbar-gutter: stable; }

body.portal {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    font-size: 1.05rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }

.portal-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(22rem, 0.95fr);
}

.portal-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.75rem;
    padding: 2.5rem clamp(1.5rem, 4vw, 3.25rem);
    color: var(--ink);
    background: #fff;
    border-right: 1px solid var(--line);
    border-bottom: 4px solid var(--ink);
    overflow: hidden;
}

.portal-home {
    display: inline-block;
    line-height: 0;
    text-decoration: none;
}

.portal-logo {
    width: min(24rem, 100%);
    height: auto;
}

.portal-home-mobile,
.portal-logo-mobile,
.portal-logo-compact {
    display: none;
    width: min(16rem, 100%);
    margin: 0 0 1.6rem;
}

.portal-logo-compact { display: block; }

.portal-logo-bar {
    width: auto;
    height: 3.15rem;
}

.portal-panel {
    display: grid;
    place-items: center;
    padding: 2.5rem 1.5rem;
    background: linear-gradient(180deg, #f7f8fa 0%, var(--paper) 55%);
}

.portal-panel-solo {
    min-height: 100vh;
    border-top: 4px solid var(--ink);
}

.portal-panel-inner {
    width: min(24rem, 100%);
    opacity: 0;
    transform: translateY(14px);
    animation: portal-rise 0.75s var(--ease) 0.08s forwards;
}

@keyframes portal-rise {
    to { opacity: 1; transform: none; }
}

.portal-mobile-mark { display: none; }

h1 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.7rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

.portal-lead,
.portal-note {
    margin: 0.75rem 0 0;
    color: var(--slate);
}

.portal-note a {
    color: var(--ink);
    font-weight: 600;
    text-underline-offset: 0.16em;
}

.portal-note a:hover { color: var(--ink); }

.portal-alert {
    margin: 1.1rem 0 0;
    padding: 0.75rem 0.9rem;
    border-radius: 6px;
    background: rgba(8, 16, 32, 0.06);
    color: var(--ink);
}

form { margin-top: 1.6rem; }

.portal-label {
    display: block;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.82rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.portal-input {
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-input:focus {
    border-color: rgba(8, 16, 32, 0.55);
    box-shadow: 0 0 0 3px rgba(8, 16, 32, 0.12);
}

.portal-button {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 650;
    letter-spacing: -0.01em;
    cursor: pointer;
}

.portal-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 1rem;
    padding: 0.9rem 1.2rem;
    border: 0;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    font-size: 0.95rem;
    transition: background 0.2s ease, transform 0.2s var(--ease);
}

.portal-button:hover {
    background: #152033;
    transform: translateY(-1px);
}

.portal-top {
    background: #fff;
}

.portal-top::after {
    content: "";
    display: block;
    height: 4px;
    background: var(--ink);
}

.portal-top-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(46rem, calc(100% - 2.5rem));
    margin: 0 auto;
    min-height: 4.25rem;
}

.portal-top form { margin: 0; }

.nav-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.35rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--slate);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.nav-logout svg {
    width: 1.2rem;
    height: 1.2rem;
}

.nav-logout:hover {
    border-color: var(--line);
    background: rgba(8, 16, 32, 0.04);
    color: var(--ink);
}

.portal-main {
    width: min(46rem, calc(100% - 2.5rem));
    margin: 0 auto;
    padding: 2.25rem 0 4rem;
}

.portal-main-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.portal-document-count {
    margin: 0.25rem 0 0;
    color: var(--slate);
    font-size: 0.9rem;
}

.portal-download-all {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.82rem;
    font-weight: 650;
    text-decoration: none;
}

.portal-download-all:hover {
    border-color: rgba(8, 16, 32, 0.35);
    background: rgba(8, 16, 32, 0.035);
}

.portal-download-all svg {
    width: 1.05rem;
    height: 1.05rem;
}

.portal-contents,
.portal-folder-contents {
    list-style: none;
    margin: 0;
    padding: 0;
}

.portal-documents {
    margin-top: 1.1rem;
    padding: 1.15rem 1.2rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.portal-documents h2 {
    margin: 0 0 0.35rem;
    color: var(--slate);
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.portal-folder-contents {
    margin: 0 0 0.15rem 1.35rem;
    padding-left: 0.85rem;
    border-left: 1px solid var(--line);
}

.portal-folder summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 0;
    border-top: 1px solid var(--line);
    color: var(--ink);
    cursor: pointer;
    list-style: none;
}

.portal-folder summary::-webkit-details-marker { display: none; }

.portal-folder summary::marker { content: ""; }

.portal-folder summary:hover .portal-folder-name { color: var(--ink); }

.portal-folder-icon,
.portal-folder-chevron {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
    color: var(--slate);
}

.portal-folder-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.95rem;
    font-weight: 650;
}

.portal-folder-chevron { transition: transform 0.15s var(--ease); }

.portal-folder[open] > summary .portal-folder-chevron { transform: rotate(90deg); }

.portal-contents > li:first-child > .portal-folder > summary,
.portal-contents > li:first-child > .portal-file-row,
.portal-folder-contents > li:first-child > .portal-folder > summary,
.portal-folder-contents > li:first-child > .portal-file-row {
    border-top: 0;
}

.portal-file-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 0;
    border-top: 1px solid var(--line);
}

.portal-file-details {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.1rem;
}

.portal-file-name {
    overflow-wrap: anywhere;
}

.portal-file-row small {
    color: var(--slate);
    font-size: 0.85rem;
}

.portal-file-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.35rem;
}

.portal-file-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--slate);
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.8rem;
    font-weight: 650;
    text-decoration: none;
}

.portal-file-action:hover {
    border-color: rgba(8, 16, 32, 0.35);
    background: rgba(8, 16, 32, 0.04);
    color: var(--ink);
}

.portal-file-action svg {
    width: 1.05rem;
    height: 1.05rem;
}

@media (max-width: 900px) {
    .portal-signin .portal-brand { display: none; }

    .portal-signin .portal-shell {
        grid-template-columns: 1fr;
        min-height: 100vh;
    }

    .portal-signin .portal-panel {
        min-height: 100vh;
        place-items: center;
        padding: 2rem 1.25rem 3rem;
        border-top: 4px solid var(--ink);
    }

    .portal-home-mobile { display: inline-block; }

    .portal-logo-mobile { display: block; }
}

@media (max-width: 520px) {
    .portal-main-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .portal-file-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.55rem;
    }

    .portal-file-actions {
        width: 100%;
    }

    .portal-file-action {
        flex: 1 1 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-panel-inner { animation: none; }

    .portal-panel-inner {
        opacity: 1;
        transform: none;
    }

    .portal-button:hover { transform: none; }

    .portal-folder-chevron { transition: none; }
}
