.ag-socio-portal {
    --sp-page: #f3f6fb;
    --sp-surface: #fff;
    --sp-subtle: #f4f7fc;
    --sp-ink: #162740;
    --sp-muted: #52657d;
    --sp-line: #d8e2ef;
    --sp-blue: #0866ff;
    --sp-button-text: #fff;
    --sp-blue-hover: #0548b5;
    --sp-blue-soft: #edf4ff;
    --sp-link: #0548b5;
    --sp-navy: #102e59;
    --sp-hero-ink: #f6f9ff;
    --sp-hero-muted: #cbdcf5;
    --sp-danger: #921d2d;
    --sp-danger-soft: #fff1f3;
    --sp-success: #145e3a;
    --sp-success-soft: #e9f8ef;
    --sp-radius: 14px;
    background: var(--sp-page);
    color: var(--sp-ink);
    font: 400 1rem/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
    margin: 0;
}

.ag-socio-portal *, .ag-socio-portal *::before, .ag-socio-portal *::after { box-sizing: border-box; }
.ag-socio-portal [hidden] { display: none !important; }
.ag-socio-portal :where(h1, h2, h3, h4, p, dl, dd) { margin: 0; }
.ag-socio-portal :where(a, button, input, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--sp-blue);
    outline-offset: 3px;
}

.ag-sp-visually-hidden, .ag-sp-skip:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    clip-path: inset(50%);
}

.ag-sp-skip:focus {
    position: fixed;
    z-index: 5;
    inset: .8rem auto auto .8rem;
    padding: .65rem .9rem;
    border-radius: 8px;
    background: var(--sp-surface);
    color: var(--sp-link);
}

.ag-sp-wrap {
    width: min(calc(100% - 3rem), 1120px);
    margin-inline: auto;
}

.ag-sp-header {
    background: var(--sp-surface);
    border-bottom: 1px solid var(--sp-line);
}

.ag-sp-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .65rem;
    min-height: 4.6rem;
}

.ag-sp-brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    color: var(--sp-ink);
    text-decoration: none;
    line-height: 1.3;
}

.ag-sp-brand-mark {
    display: grid;
    flex: 0 0 44px;
    place-items: center;
    width: 44px;
    height: 44px;
    background: var(--sp-blue);
    color: var(--sp-button-text);
    border-radius: 12px;
    font-size: 1.35rem;
    font-weight: 750;
}

.ag-sp-brand strong { display: block; font-size: 1rem; }
.ag-sp-brand strong + span { display: block; color: var(--sp-muted); font-size: .82rem; }

.ag-sp-button {
    min-height: 44px;
    padding: .55rem .95rem;
    border: 1px solid transparent;
    border-radius: 9px;
    font: 650 .94rem/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
}

.ag-sp-button-quiet {
    background: var(--sp-surface);
    border-color: var(--sp-line);
    color: var(--sp-ink);
    white-space: nowrap;
}

.ag-sp-button-quiet:hover { border-color: var(--sp-blue); color: var(--sp-link); }
.ag-sp-button-primary { background: var(--sp-blue); color: var(--sp-button-text); }
.ag-sp-button-primary:hover { background: var(--sp-blue-hover); }

.ag-sp-entry {
    display: grid;
    grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 1rem;
    max-width: 940px;
    padding-block: clamp(1.5rem, 6vw, 5rem);
}

.ag-sp-entry-card, .ag-sp-entry-intro { padding: clamp(1.45rem, 4vw, 3rem); border-radius: var(--sp-radius); }
.ag-sp-entry-intro {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    background: var(--sp-navy);
    color: var(--sp-hero-ink);
}

.ag-sp-entry-title {
    font-size: clamp(1.85rem, 3.8vw, 3.4rem);
    font-weight: 720;
    line-height: 1.08;
    letter-spacing: -.045em;
    text-wrap: balance;
}

.ag-sp-entry-intro p:last-child { max-width: 34ch; color: var(--sp-hero-muted); }
.ag-sp-entry-card { background: var(--sp-surface); border: 1px solid var(--sp-line); }
.ag-sp-entry-card h1, .ag-sp-overview h1 { font-size: clamp(1.65rem, 3vw, 2.6rem); letter-spacing: -.035em; line-height: 1.16; }
.ag-sp-entry-card > p:not([role]) { color: var(--sp-muted); margin-top: .6rem; }
.ag-sp-entry-card > .ag-sp-entry-note { margin-top: 1.05rem; font-size: .89rem; }
.ag-sp-entry-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--sp-link); font-size: .89rem; font-weight: 650; }

.ag-sp-form { display: grid; gap: 1rem; margin-block: 1.2rem .2rem; }
.ag-sp-form label { display: block; margin-bottom: .3rem; font-size: .91rem; font-weight: 650; }
.ag-sp-form input:not([type="hidden"]) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--sp-line);
    border-radius: 8px;
    background: var(--sp-surface);
    color: var(--sp-ink);
    padding: .55rem .7rem;
    font: inherit;
}

.ag-sp-field-help { margin-top: .3rem; color: var(--sp-muted); font-size: .82rem; }
.ag-sp-alert, .ag-sp-notice { border-radius: 9px; padding: .68rem .85rem; font-size: .9rem; }
.ag-sp-alert { background: var(--sp-danger-soft); color: var(--sp-danger); margin-top: 1rem; }
.ag-sp-notice { background: var(--sp-blue-soft); color: var(--sp-link); }
.ag-sp-entry-card > .ag-sp-notice { margin-top: 1rem; }

.ag-sp-dashboard { padding-block: 1.65rem 3.5rem; }
.ag-sp-dashboard > .ag-sp-notice { margin-top: 1rem; }
.ag-sp-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: clamp(1.15rem, 3vw, 2rem);
    background: var(--sp-navy);
    color: var(--sp-hero-ink);
    border-radius: var(--sp-radius);
}
.ag-sp-overview h1 { margin-block: .35rem .45rem; overflow-wrap: anywhere; }
.ag-sp-overview p { color: var(--sp-hero-muted); }
.ag-sp-overview .ag-sp-folio, .ag-sp-ref { font-size: .77rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.ag-sp-totals { display: grid; grid-template-columns: repeat(2, minmax(6.8rem, 1fr)); gap: .65rem; }
.ag-sp-totals > div { min-width: 0; padding: .65rem .85rem; border: 1px solid #607aa1; border-radius: 10px; }
.ag-sp-totals dt { color: var(--sp-hero-muted); font-size: .8rem; }
.ag-sp-totals dd { font-size: clamp(1.25rem, 3vw, 2rem); font-weight: 700; line-height: 1.25; }

.ag-sp-section-title { margin: 1.7rem 0 .8rem; font-size: 1.35rem; letter-spacing: -.018em; }
.ag-sp-group + .ag-sp-group { margin-top: 1.55rem; }
.ag-sp-group h3 { color: var(--sp-muted); font-size: .96rem; margin-bottom: .55rem; overflow-wrap: anywhere; }
.ag-sp-empty, .ag-sp-agreement { background: var(--sp-surface); border: 1px solid var(--sp-line); border-radius: var(--sp-radius); }
.ag-sp-empty { color: var(--sp-muted); padding: 1rem 1.15rem; }
.ag-sp-agreement { padding: clamp(.85rem, 2.5vw, 1.25rem); }
.ag-sp-agreement + .ag-sp-agreement { margin-top: .75rem; }
.ag-sp-agreement-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.ag-sp-agreement-header > div { min-width: 0; overflow-wrap: anywhere; }
.ag-sp-agreement-header h4 { margin-block: .05rem .12rem; font-size: 1.17rem; letter-spacing: -.015em; }
.ag-sp-ref, .ag-sp-muted { color: var(--sp-muted); }
.ag-sp-muted { font-size: .9rem; }
.ag-sp-badge {
    flex: 0 0 auto;
    padding: .23rem .6rem;
    border-radius: 99px;
    background: var(--sp-blue-soft);
    color: var(--sp-link);
    font-size: .79rem;
    font-weight: 650;
}

.ag-sp-badge-settled { background: var(--sp-success-soft); color: var(--sp-success); }

.ag-sp-metrics, .ag-sp-dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.ag-sp-metrics { margin-block: .85rem .7rem; }
.ag-sp-metrics > div { padding: .6rem .72rem; border-radius: 9px; background: var(--sp-subtle); }
.ag-sp-metrics dt, .ag-sp-dates dt { color: var(--sp-muted); font-size: .83rem; }
.ag-sp-metrics dd, .ag-sp-dates dd { font-variant-numeric: tabular-nums; font-weight: 650; overflow-wrap: anywhere; }
.ag-sp-metrics dd { font-size: clamp(.94rem, 2.15vw, 1.13rem); line-height: 1.32; margin-top: .15rem; }
.ag-sp-dates { margin-block: .85rem; }
.ag-sp-dates dd { font-size: .88rem; }

.ag-sp-ledger { border-top: 1px solid var(--sp-line); }
.ag-sp-ledger summary {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-height: 44px;
    padding: .32rem .25rem;
    cursor: pointer;
    font-weight: 650;
    font-size: .91rem;
    list-style: none;
}
.ag-sp-ledger summary::-webkit-details-marker { display: none; }
.ag-sp-ledger summary::before {
    content: '';
    width: .46rem;
    height: .46rem;
    margin-right: .18rem;
    border-bottom: 2px solid var(--sp-link);
    border-right: 2px solid var(--sp-link);
    transform: rotate(-45deg);
}
.ag-sp-ledger[open] summary::before { transform: rotate(45deg); }
.ag-sp-ledger-count { margin-left: auto; color: var(--sp-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.ag-sp-table-frame { overflow-x: auto; margin-bottom: .75rem; border: 1px solid var(--sp-line); border-radius: 8px; }
.ag-sp-table { width: 100%; border-collapse: collapse; font-size: .86rem; table-layout: auto; }
.ag-sp-table th, .ag-sp-table td { padding: .55rem .65rem; text-align: left; vertical-align: top; }
.ag-sp-table th { background: var(--sp-subtle); color: var(--sp-muted); font-weight: 650; }
.ag-sp-table td { border-top: 1px solid var(--sp-line); }
.ag-sp-table .ag-sp-amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ag-sp-cell-heading { display: none; }

@media (max-width: 660px) {
    .ag-sp-wrap { width: calc(100% - 2rem); }
    .ag-sp-entry { grid-template-columns: 1fr; gap: .7rem; padding-block: .9rem 2rem; }
    .ag-sp-entry-intro { gap: .45rem; }
    .ag-sp-entry-intro p:last-child { font-size: .9rem; }
    .ag-sp-overview { grid-template-columns: 1fr; }
    .ag-sp-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ag-sp-metrics { grid-template-columns: 1fr; gap: .3rem; }
    .ag-sp-metrics > div { display: flex; justify-content: space-between; align-items: baseline; gap: .65rem; }
    .ag-sp-metrics dd { text-align: right; margin: 0; }
    .ag-sp-dates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
    .ag-sp-table, .ag-sp-table tbody { display: block; }
    .ag-sp-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .ag-sp-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: .25rem .38rem;
    }
    .ag-sp-table tbody tr + tr { border-top: 1px solid var(--sp-line); }
    .ag-sp-table td, .ag-sp-table .ag-sp-amount {
        display: block;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: left;
        padding: .25rem .38rem;
        border: 0;
    }
    .ag-sp-cell-heading { display: block; color: var(--sp-muted); font-size: .75rem; }
}

@media (prefers-color-scheme: dark) {
    .ag-socio-portal {
        color-scheme: dark;
        --sp-page: #101828;
        --sp-surface: #162236;
        --sp-subtle: #1b2a40;
        --sp-ink: #eef4ff;
        --sp-muted: #bbcae0;
        --sp-line: #354866;
        --sp-blue: #6daaff;
        --sp-button-text: #10213a;
        --sp-blue-hover: #91bdff;
        --sp-blue-soft: #243d65;
        --sp-link: #c2daff;
        --sp-navy: #17345b;
        --sp-danger: #ffd5da;
        --sp-danger-soft: #4a2937;
        --sp-success: #b5edcb;
        --sp-success-soft: #1d4939;
    }
}
