/* ===========================================================================
   Missing Cash Locator — member portal (Phase E / 2026)
   Extends ../includes/style.css variables. Do not redefine brand tokens here.
   =========================================================================== */

:root {
    --portal-radius: 12px;
    --portal-shadow:
        0 1px 3px rgba(0, 0, 0, 0.06),
        0 6px 20px rgba(31, 92, 49, 0.06);
    --portal-shadow-hover:
        0 2px 6px rgba(0, 0, 0, 0.08),
        0 10px 28px rgba(31, 92, 49, 0.1);
    --portal-header: #143d22;
    --portal-header-deep: #0f2f1a;
}

/* ── Page shell ──────────────────────────────────────────────────────────── */

.portal-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse 90% 55% at 50% -15%, rgba(31, 92, 49, 0.11), transparent 55%),
        linear-gradient(180deg, #f3f6f3 0%, var(--background-color) 42%);
}

main.portal {
    flex: 1;
    padding: 1.75rem 20px 3.5rem;
}

main.portal > h1 {
    margin-top: 0.35rem;
    letter-spacing: -0.02em;
}

.portal-footer {
    margin-top: auto;
    background: var(--portal-header-deep);
    color: rgba(255, 255, 255, 0.78);
    padding: 1.35rem 0;
    border-top: 0;
}

.portal-footer a { color: #b8e0c4; }
.portal-footer .muted,
.portal-footer p { color: rgba(255, 255, 255, 0.65); font-size: 0.9rem; margin: 0.25rem 0; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* ── Header (dark green) ─────────────────────────────────────────────────── */

.portal-body > .brand-bar {
    background: linear-gradient(135deg, var(--portal-header) 0%, var(--accent-green) 100%);
    border-bottom: 0;
    padding: 1rem 0;
    text-align: left;
    box-shadow: 0 4px 18px rgba(15, 47, 26, 0.28);
}

.portal-body > .brand-bar .brand {
    display: block;
    max-width: var(--column);
    margin: 0 auto;
    padding: 0 20px;
    color: #fff;
    font-size: 1.05rem;
    letter-spacing: 0.6px;
}

.portal-body > .brand-bar .brand span {
    color: #c8f0d4;
}

.portal-body > .brand-bar .brand:hover {
    color: #fff;
}

/* ── Nav — pill / tab bar (full-width, single row, scroll on overflow) ───── */

.portal-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    padding: 0.65rem 16px;
    margin-top: -0.15rem;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--rule);
    backdrop-filter: blur(8px);
    font-family: var(--head-font);
    font-weight: 700;
    font-size: 0.82rem;
    position: sticky;
    top: 0;
    z-index: 40;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.portal-nav::-webkit-scrollbar {
    display: none; /* Chrome / Safari — scroll remains functional */
}

.portal-nav a {
    color: var(--main-font-color);
    text-decoration: none;
    padding: 0.4rem 0.72rem;
    min-height: 40px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.portal-nav a:hover {
    background: rgba(31, 92, 49, 0.08);
    color: var(--accent-green);
}

.portal-nav a.nav-active {
    background: var(--accent-green);
    color: #fff;
}

.portal-nav a.nav-active:hover {
    background: var(--accent-green-dark);
    color: #fff;
}

.portal-nav a.nav-locked {
    color: var(--muted);
    cursor: pointer;
    background: transparent;
}

.portal-nav a.nav-locked:hover {
    background: rgba(31, 92, 49, 0.08);
    color: var(--accent-green);
}

.portal-nav .nav-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
    padding-left: 0.35rem;
}

/* Mobile swipe hint — fade + chevron at the right edge */
.portal-nav::after {
    content: "›";
    position: sticky;
    right: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 48px;
    flex-shrink: 0;
    margin-left: -48px;
    padding-right: 6px;
    box-sizing: border-box;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
    color: var(--muted);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95) 42%);
    pointer-events: none;
}

@media (min-width: 900px) {
    .portal-nav {
        justify-content: center;
        padding-left: 7rem;  /* room so centered links aren't under logout */
        padding-right: 7rem;
        overflow-x: visible;
    }

    .portal-nav::after {
        display: none;
    }

    .portal-nav .nav-right {
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 0;
        padding-left: 0;
    }
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    background: var(--accent-green);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ── Cards / panels ──────────────────────────────────────────────────────── */

.portal-card,
.portal-panel {
    background: #fff;
    border: 1px solid rgba(227, 227, 227, 0.9);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 1.45rem 1.5rem;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.portal-card-grid .portal-panel:hover {
    box-shadow: var(--portal-shadow-hover);
    transform: translateY(-2px);
}

.portal-panel h2,
.portal-panel h3 {
    margin-top: 0;
}

.portal-panel p:last-child { margin-bottom: 0; }

/* A trailing hint (e.g. "confirm on the official site") needs breathing room above it:
   a bare <p> has no margin-top, so it would otherwise sit flush against the buttons. */
.portal-panel p.hint:not(:first-child) { margin-top: 1.1rem; }

/* Stacked guide panels (keep-it, claim-kit, etc.) — not grid cards */
main.portal > .portal-panel + .portal-panel {
    margin-top: 1.25rem;
}

.portal-panel--yours {
    background: linear-gradient(160deg, #f3faf5 0%, #fff 55%);
    border: 1px solid rgba(31, 92, 49, 0.35);
    border-left: 5px solid var(--accent-green);
    box-shadow: var(--portal-shadow);
}

.portal-panel--yours.is-focus,
.portal-panel.is-focus {
    box-shadow: 0 0 0 3px rgba(31, 92, 49, 0.22), var(--portal-shadow);
}

.portal-card-grid {
    display: grid;
    gap: 1.25rem;
    margin: 1.5rem 0;
}

@media (min-width: 640px) {
    .portal-card-grid.cols-2 { grid-template-columns: 1fr 1fr; }
}

.portal-card-grid .portal-panel {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.portal-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.portal-card-head .icon-chip {
    margin-bottom: 0;
}

.portal-card-head .feature-pill,
.portal-card-head .feature-pill--yours {
    margin-bottom: 0;
}

.portal-card-grid .portal-panel > .cta-btn,
.portal-card-grid .portal-panel > p:has(.cta-btn),
.portal-card-grid .portal-panel > p:has(.btn-secondary) {
    margin-top: auto;
    padding-top: 0.85rem;
}

.icon-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 10px;
    background: rgba(31, 92, 49, 0.1);
    color: var(--accent-green);
    font-size: 1.15rem;
    margin-bottom: 0.65rem;
    line-height: 1;
}

.portal-panel--yours .icon-chip {
    background: var(--accent-green);
    color: #fff;
}

.feature-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--accent-green);
    margin-bottom: 0.6rem;
    white-space: nowrap;
}

.feature-pill--yours {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: var(--accent-green);
    color: #fff;
    padding: 0.32rem 0.85rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    margin-bottom: 0.6rem;
}

.pill-locked {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #f0f0f0;
    color: var(--muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0.35rem 0.35rem 0.35rem 0;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pill-locked:hover {
    border-color: rgba(31, 92, 49, 0.35);
    background: #eef6f0;
    color: var(--accent-green-dark);
}

.pill-locked:focus-visible {
    outline: 3px solid rgba(31, 92, 49, 0.45);
    outline-offset: 2px;
}

.locked-modules {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1rem 0 0;
    padding: 1.15rem;
    background: #fff;
    border: 1px dashed var(--rule);
    border-radius: var(--portal-radius);
}

.locked-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.state-lib-heading {
    margin: 1.75rem 0 0.35rem;
    font-size: 1.15rem;
}

.state-lib-sub {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

/* ── Flash / alerts ──────────────────────────────────────────────────────── */

.flash {
    padding: 0.9rem 1.1rem;
    margin: 1rem 0;
    border-radius: 10px;
    border: 1px solid rgba(31, 92, 49, 0.18);
    border-left: 4px solid var(--accent-green);
    background: #eef6f0;
}

.flash-error {
    border-color: rgba(198, 40, 40, 0.2);
    border-left-color: var(--accent-red);
    background: #fdf2f2;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-stack label {
    display: block;
    font-weight: 700;
    font-size: 0.88rem;
    margin: 1.05rem 0 0.4rem;
}

.form-stack input[type="text"],
.form-stack input[type="email"],
.form-stack input[type="password"],
.form-stack input[type="tel"],
.form-stack input[type="date"],
.form-stack select,
.form-stack textarea {
    width: 100%;
    max-width: min(420px, 100%);
    padding: 0.72rem 0.85rem;
    border: 1px solid var(--rule);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-stack textarea { max-width: 100%; min-height: 88px; }

/* ── Exit survey: reason options ─────────────────────────────────────────── */

.reason-set {
    border: 0;
    padding: 0;
    margin: 1.05rem 0 0.4rem;
}

.reason-set legend {
    padding: 0;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 0.88rem;
}

.reason-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.reason-option:hover {
    border-color: var(--accent-green);
    background: #f7fbf8;
}

.reason-option input {
    flex: 0 0 auto;
    margin-top: 0.18rem;
}

.reason-option:has(input:checked) {
    border-color: var(--accent-green);
    background: #eef6f0;
}

.reason-option:has(input:focus-visible) {
    outline: 2px solid var(--accent-green);
    outline-offset: 1px;
}

.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(31, 92, 49, 0.18);
}

.form-stack .hint {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.form-actions { margin-top: 1.5rem; }

.info-pill {
    display: inline-block;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: rgba(31, 92, 49, 0.1);
    color: var(--accent-green-dark);
    font-size: 0.86rem;
    font-weight: 600;
    margin: 0.35rem 0 1rem;
}

/* Auth card (login / reset) */

.auth-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 16px 3rem;
    width: 100%;
    box-sizing: border-box;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--portal-shadow-hover);
    border: 1px solid rgba(227, 227, 227, 0.85);
    padding: 2rem 1.5rem 1.75rem;
    box-sizing: border-box;
}

.auth-card h1 {
    margin: 0.5rem 0 0.65rem;
    font-size: 1.55rem;
    text-align: center;
}

.auth-card .auth-brand {
    display: block;
    text-align: center;
    font-family: var(--head-font);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--main-font-color);
    text-decoration: none;
    font-size: 0.95rem;
}

.auth-card .auth-brand span { color: var(--accent-green); }

.auth-card .form-stack input {
    max-width: none;
}

.auth-card .form-actions .cta-btn,
.auth-card .cta-btn {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
}

.auth-card .auth-footer-link {
    text-align: center;
    margin: 1.25rem 0 0;
}

/* Deliberately quiet: the close-account route sits at the bottom of the page
   where people look for it, not in the middle of the product. */
.quiet-link {
    margin: 2rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ── State picker chips ──────────────────────────────────────────────────── */

.state-picker {
    max-width: 520px;
    margin: 0.35rem 0 1.25rem;
}

.state-picker-add {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.state-picker-add select {
    flex: 1 1 220px;
    max-width: none;
    width: auto;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--rule);
    font: inherit;
    background: #fff;
}

.state-picker-list {
    list-style: none;
    margin: 0.85rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border: 0;
    background: transparent;
}

.state-picker-list:empty { display: none; }

.state-picker-list li {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.55rem 0.4rem 0.75rem;
    border: 1px solid rgba(31, 92, 49, 0.25);
    border-radius: 999px;
    background: #eef6f0;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(31, 92, 49, 0.25);
}

.state-picker-list li span { flex: 1; }

.state-picker-list abbr {
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
}

.state-picker-remove {
    border: 0;
    background: rgba(198, 40, 40, 0.1);
    color: var(--accent-red);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}

.state-picker-remove:hover {
    background: rgba(198, 40, 40, 0.18);
    text-decoration: none;
}

.state-picker-empty[hidden] { display: none; }

/* ── Guides / sources / results ──────────────────────────────────────────── */

.guide-block {
    margin-bottom: 1.25rem;
}

.guide-block h2 { margin-bottom: 0.5rem; }

.guide-block h3 {
    font-size: 1rem;
    margin: 1rem 0 0.4rem;
}

.guide-caution {
    background: #fdf2f2;
    border-left: 4px solid var(--accent-red);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
}

.code-block {
    background: #14301c;
    color: #d7f0df;
    padding: 0.95rem 1.05rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.45;
    border-radius: 10px;
}

.source-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    display: grid;
    gap: 0.85rem;
}

.source-list li {
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--rule);
    border-radius: var(--portal-radius);
    background: #fff;
    box-shadow: var(--portal-shadow);
    border-bottom: 1px solid var(--rule);
}

.source-list li:last-child { border-bottom: 1px solid var(--rule); }

.source-list h3 { margin: 0 0 0.4rem; }

/* ── Source rows: already-searched state ─────────────────────────────────── */

.source-list li.is-searched,
.guide-block.is-searched {
    border-left: 5px solid var(--accent-green);
    background: linear-gradient(90deg, #e9f5ed 0%, #fbfdfc 65%);
}

.searched-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(31, 92, 49, 0.25);
    border-radius: 999px;
    background: #e4f3e9;
    color: var(--accent-green);
    font-family: var(--head-font);
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1;
}

/* Quiet undo action, shown only once a source is marked searched. */
.btn-link {
    background: none;
    border: 0;
    padding: 0.35rem 0.2rem;
    color: var(--muted);
    font-family: var(--head-font);
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}

.btn-link:hover { color: var(--accent-green); }

/* ── Survey console (admin) ──────────────────────────────────────────────── */

.admin-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    margin: 0.5rem 0 1rem;
}

.admin-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.admin-stat .stat-num {
    font-size: 1.9rem;
    line-height: 1;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    padding: 0.6rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
}

.admin-table thead th {
    font-family: var(--head-font);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.admin-table tbody tr:last-child td { border-bottom: 1px solid var(--rule); }

.admin-table tfoot th {
    border-top: 2px solid var(--rule);
    border-bottom: 0;
    font-family: var(--head-font);
}

.admin-table .num {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

/* Timestamps are one unbreakable value — never wrap them onto two lines. */
.cell-when { white-space: nowrap; }

/* With the account card open the page behind it must not scroll away. */
html:has(.admin-modal-backdrop) { overflow: hidden; }

/* The console needs the width the member pages deliberately do not use. */
.wrap--wide { max-width: 1200px; }

/* Under 760px an admin table stops being a table: each row becomes a card and
   every cell carries its column name. Nothing squeezes, nothing scrolls. */
@media (max-width: 760px) {
    .admin-table--cards { display: block; }
    .admin-table--cards thead { display: none; }
    .admin-table--cards tbody,
    .admin-table--cards tfoot,
    .admin-table--cards tr,
    .admin-table--cards th,
    .admin-table--cards td { display: block; width: auto; }

    .admin-table--cards tbody tr,
    .admin-table--cards tfoot tr {
        border: 1px solid var(--rule);
        border-radius: var(--portal-radius);
        background: #fff;
        padding: 0.7rem 0.85rem;
        margin-bottom: 0.7rem;
    }

    .admin-table--cards tfoot tr { background: var(--background-color); }

    .admin-table--cards td,
    .admin-table--cards th {
        display: block;
        border: 0;
        padding: 0.35rem 0 0;
        text-align: left;
    }

    .admin-table--cards td::before,
    .admin-table--cards tfoot th::before {
        content: attr(data-label);
        display: block;
        font-family: var(--head-font);
        font-size: 0.66rem;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--muted);
        margin-bottom: 0.15rem;
    }

    /* Numbers read better beside their label than underneath it. */
    .admin-table--cards td.num,
    .admin-table--cards tfoot th.num {
        display: flex;
        align-items: baseline;
        gap: 0.6rem;
        padding: 0.2rem 0;
    }

    .admin-table--cards td.num::before,
    .admin-table--cards tfoot th.num::before {
        flex: 0 0 6.5rem;
        margin-bottom: 0;
    }

    /* A chip is one word: never let it break mid-word on a narrow screen. */
    .admin-table--cards .pack-chip { white-space: nowrap; }

    .admin-table--cards tfoot th {
        font-size: 0.9rem;
        padding: 0.24rem 0;
    }

    .admin-table--cards td.cell-manage::before { display: none; }
    .admin-table--cards td.cell-manage { padding-top: 0.6rem; }
    .admin-table--cards td.cell-manage .btn-sm { width: 100%; text-align: center; }

    .admin-summary__row { flex-direction: column; gap: 1rem; }
    .pack-list { margin-left: 0; }
}

.ca-results h3 { margin-bottom: 0.35rem; }

.result-hit {
    border-left: 5px solid var(--accent-green) !important;
    background: linear-gradient(90deg, #f3faf5 0%, #fff 40%) !important;
}

.stat-num {
    display: block;
    font-family: var(--head-font);
    font-weight: 800;
    font-size: 2.35rem;
    line-height: 1.1;
    color: var(--accent-green);
    letter-spacing: -0.03em;
    margin: 0.15rem 0 0.35rem;
}

.stat-card .muted { margin-bottom: 0; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

/* "Where do I find my order ID?" — a collapsed help card under the login form.
   Card look + a rotating chevron + fade-in for the revealed content. */
.auth-help {
    margin-top: 1.25rem;
    border: 1px solid rgba(227, 227, 227, 0.9);
    border-radius: 12px;
    background: #fafcfa;
    padding: 0 0.9rem;
    overflow: hidden;
}

.auth-help summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    font-family: var(--head-font);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--main-font-color);
}

.auth-help summary::-webkit-details-marker { display: none; }

/* Chevron drawn in CSS (no icon font) that points down, then up when opened. */
.auth-help summary::after {
    content: '';
    margin-left: auto;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--accent-green);
    border-bottom: 2px solid var(--accent-green);
    transform: rotate(45deg);
    transition: transform 0.22s ease;
}

.auth-help[open] summary::after { transform: rotate(-135deg); }

.auth-help[open] summary {
    border-bottom: 1px solid rgba(227, 227, 227, 0.9);
    padding-bottom: 0.65rem;
}

.auth-help > ul {
    margin: 0.75rem 0 0.95rem;
    padding-left: 1.1rem;
    font-size: 0.86rem;
    line-height: 1.55;
}

.auth-help > ul li + li { margin-top: 0.3rem; }

details.auth-help[open] > ul { animation: authHelpReveal 0.24s ease-out both; }

@keyframes authHelpReveal {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    details.auth-help[open] > ul { animation: none; }
    .auth-help summary::after { transition: none; }
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.75rem;
}

button.cta-btn,
.form-actions .cta-btn {
    display: inline-block;
    width: auto;
    max-width: none;
    margin: 0;
    border: 0;
    cursor: pointer;
    font-size: 1rem;
    padding: 14px 22px;
    border-radius: 8px;
}

.btn-row .cta-btn {
    display: inline-block;
    width: auto;
    max-width: none;
    margin: 0;
    font-size: 0.95rem;
    padding: 12px 18px;
    border-radius: 8px;
}

.portal-body .cta-btn {
    border-radius: 8px;
    box-shadow: 0 3px 0 var(--accent-green-dark);
}

.portal-body .cta-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--accent-green-dark);
}

.btn-secondary {
    display: inline-block;
    padding: 0.55rem 1rem;
    border: 1.5px solid var(--accent-green);
    border-radius: 8px;
    color: var(--accent-green);
    text-decoration: none;
    font-family: var(--head-font);
    font-weight: 700;
    font-size: 0.9rem;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
    background: rgba(31, 92, 49, 0.08);
}

/* Stacked call-to-action: a wide, centred button with its caption underneath. */
.btn-row--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    text-align: center;
}

.btn-row--stack .cta-btn--wide {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 14px 22px;
    font-size: 1rem;
    text-align: center;
}

/* ── Claim print ─────────────────────────────────────────────────────────── */

.claim-print {
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: var(--portal-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: none;
}

.claim-print h2 { margin-top: 0; }

/* body is a column flex container, so <main> is a flex item. Its `.wrap`
   `margin: 0 auto` stops the cross-axis stretch, leaving it sized fit-content —
   so one wide child (the 6-column audit worksheet) inflates the whole page and
   gives it a horizontal scrollbar. A definite width pins it to the viewport and
   lets wide content scroll inside its own container instead. */
.portal-body > main { width: 100%; min-width: 0; }

/* A fill-in line is one long unbreakable token (a run of underscores). Without
   this it overflows its box and gives the page horizontal scroll on a phone.
   Scoped to prose — NOT to the table, whose column words must wrap whole. */
.claim-print p,
.claim-print li { overflow-wrap: anywhere; }

/* ── Focus / a11y ────────────────────────────────────────────────────────── */

.portal-nav a:focus-visible,
.cta-btn:focus-visible,
.btn-secondary:focus-visible,
.state-picker-remove:focus-visible {
    outline: 3px solid rgba(31, 92, 49, 0.45);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .portal-card-grid .portal-panel,
    .portal-nav a,
    .btn-secondary,
    .portal-body .cta-btn {
        transition: none;
    }
    .portal-card-grid .portal-panel:hover {
        transform: none;
    }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 639px) {
    .portal-nav {
        gap: 0.3rem;
        padding: 0.55rem 12px;
        /* keep sticky + single-row horizontal scroll (do not force wrap) */
    }

    .portal-nav a {
        padding: 0.38rem 0.68rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    .portal-nav .nav-right {
        margin-left: auto;
        width: auto;
    }

    .stat-num { font-size: 1.85rem; }

    .auth-card { padding: 1.5rem 1.15rem; }

    .btn-row {
        flex-wrap: wrap;
    }

    .source-list li,
    .portal-panel {
        overflow-wrap: anywhere;
    }
}

/* ── Upsell modal (Phase H) ──────────────────────────────────────────────── */

.upsell-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.upsell-modal[hidden] {
    display: none;
}

.upsell-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 47, 26, 0.45);
    backdrop-filter: blur(2px);
}

.upsell-modal-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 47, 26, 0.35);
    padding: 1.75rem 1.5rem 1.5rem;
    z-index: 1;
}

.upsell-modal-x {
    position: absolute;
    top: 0.7rem;
    right: 0.85rem;
    border: 0;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.upsell-modal-card h2 {
    margin: 0 0 0.75rem;
    color: var(--accent-green);
}

.upsell-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
    align-items: center;
}

.upsell-modal-actions .cta-btn {
    display: inline-block;
    width: auto;
    max-width: none;
    margin: 0;
}

.upsell-modal-actions .cta-btn[aria-disabled="true"],
.upsell-modal-actions .cta-btn.is-disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* ── Print ───────────────────────────────────────────────────────────────── */

/* Kill the browser's own print header/footer (date + page title + URL + page numbers).
   Chrome/Edge/Safari draw them inside the @page margin box, so a zero page margin
   removes them entirely; the printable document supplies its own padding below. */
@page { margin: 0; }

@media print {
    /* Chrome that never belongs on paper. */
    .no-print,
    .brand-bar,
    .portal-nav,
    .portal-footer,
    .upsell-modal { display: none !important; }

    /* A page that offers a printable document (a claim letter / template) prints ONLY that
       document — never the page intro, the panels, the network tabs or buttons. Everything
       except .claim-print is removed from flow; .claim-print and its ancestors stay, so the
       letter still starts at the top of page 1. Scoped with :has() so pages WITHOUT a
       printable letter (dashboard, search, …) keep their normal print behaviour. */
    body:has(.claim-print) *:not(.claim-print):not(.claim-print *):not(:has(.claim-print)) {
        display: none !important;
    }

    .claim-print {
        border: 0;
        box-shadow: none;
        border-radius: 0;
        margin: 0;
        /* Own page margins, since @page margin is zeroed above. Tight enough that
           a one-page letter stays on one page. */
        padding: 10mm 14mm;
    }

    .portal-body { background: #fff; }
}

/* ── Admin: enrolled users ───────────────────────────────────────────────── */

.admin-search {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
    margin: 0.5rem 0 0;
}

.admin-search label {
    flex: 1 1 100%;
    font-size: 0.8rem;
    color: var(--muted);
}

.admin-search input { flex: 1 1 220px; }

.admin-users td { vertical-align: top; }

/* Pack chips are short; without a hint the auto layout hands them all the
   spare width and starves Account, Status and the timestamps. */
.admin-users th:nth-child(1) { width: 30%; }
.admin-users th:nth-child(2) { width: 24%; }
.admin-users th:nth-child(3),
.admin-users th:nth-child(4),
.admin-users th:nth-child(5),
.admin-users td:nth-child(3),
.admin-users td:nth-child(4),
.admin-users td:nth-child(5) { width: 1%; white-space: nowrap; }

/* Same for the response list: the source chip and the timestamp are fixed
   width, so the prose columns get everything that is left. */
.admin-responses th:nth-child(1),
.admin-responses td:nth-child(1),
.admin-responses th:nth-child(5),
.admin-responses td:nth-child(5) { width: 1%; white-space: nowrap; }

.admin-responses th:nth-child(3) { width: 26%; }

/* The summary table is seven short rows — stretched across the full console it
   would put the counts a screen away from the labels they belong to. */
.admin-answers { max-width: 760px; }

.admin-actions,
.admin-delete {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.5rem;
}

.admin-delete { margin: 0; }

.admin-actions input[type="password"] {
    width: 11rem;
    max-width: 100%;
    font-size: 0.85rem;
    padding: 0.4rem 0.55rem;
}

.btn-danger {
    font-family: var(--head-font);
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    background: #b3261e;
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
}

.btn-danger:hover { background: #8f1d17; }

.pack-chip {
    display: inline-block;
    font-size: 0.72rem;
    line-height: 1.6;
    padding: 0 0.5rem;
    margin: 0 0.25rem 0.25rem 0;
    border-radius: 20px;
    background: #eef5ef;
    color: var(--accent-green);
    border: 1px solid rgba(31, 92, 49, 0.22);
}

.pack-chip--admin {
    background: #fdf4e0;
    color: #8a6a12;
    border-color: rgba(138, 106, 18, 0.3);
}

/* ── Shared admin header ─────────────────────────────────────────────────── */

.admin-bar {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--portal-header-deep);
    color: #ffffff;
}

.admin-bar__inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    min-height: 54px;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.admin-bar__brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--head-font);
    font-size: 0.95rem;
}

.admin-badge {
    display: inline-block;
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
    background: var(--accent-green);
    color: #ffffff;
    border-radius: 4px;
    padding: 0.22rem 0.45rem;
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
}

.admin-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--head-font);
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 999px;
    white-space: nowrap;
}

.admin-nav__link:hover { color: #ffffff; border-color: rgba(255, 255, 255, 0.35); }

.admin-nav__link.is-active {
    background: #ffffff;
    color: var(--accent-green-dark);
}

.admin-nav__count {
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    padding: 0 0.42rem;
}

.admin-nav__link.is-active .admin-nav__count {
    background: #eef5ef;
    color: var(--accent-green-dark);
}

.admin-exit {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
}

.admin-exit:hover { color: #ffffff; text-decoration: underline; }

/* ── Admin: summary row (stats + pack breakdown in one panel) ────────────── */

.admin-summary__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.25rem 2.5rem;
}

.pack-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-left: auto;
}

.pack-list__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

/* ── Admin: account detail modal ─────────────────────────────────────────── */

.admin-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(12, 24, 16, 0.62);
    overflow-y: auto;
    padding: 3rem 1rem;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.admin-modal {
    width: 100%;
    max-width: 560px;
    background: #ffffff;
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow-hover);
    padding: 1.5rem;
    margin: auto;
}

.admin-modal__head { margin-bottom: 1rem; }
.admin-modal__head strong { display: block; font-family: var(--head-font); font-size: 1.1rem; word-break: break-word; }
.admin-modal__head .muted { font-size: 0.85rem; }

.admin-modal__facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 1rem;
    margin: 0 0 1.25rem;
    font-size: 0.88rem;
}

.admin-modal__facts dt {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 0.15rem;
}

.admin-modal__facts dd { margin: 0; }

.admin-modal__section {
    border-top: 1px solid var(--rule);
    padding-top: 1rem;
    margin-top: 1rem;
}

.admin-modal__section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-family: var(--head-font);
}

.admin-modal__section label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.admin-modal__section input[type="password"] { width: 100%; }

.admin-danger {
    border: 1px dashed rgba(179, 38, 30, 0.55);
    background: #fdf3f2;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-top: 1.25rem;
}

.admin-danger__label {
    display: block;
    font-family: var(--head-font);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #b3261e;
    margin-bottom: 0.4rem;
}

.admin-danger p { margin: 0 0 0.7rem; font-size: 0.85rem; }

.admin-modal__close { display: inline-block; margin-top: 1rem; }

.btn-sm {
    font-size: 0.78rem;
    padding: 0.35rem 0.8rem;
}

.cell-manage {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

/* Note cells keep the whole sentence; three lines until the operator opens it. */
.note-cell { margin: 0; }

.note-cell > summary {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    list-style: none;
}

.note-cell > summary::-webkit-details-marker { display: none; }

.note-cell > summary::after {
    content: " ▾";
    color: var(--muted);
}

.note-cell[open] > summary {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
}

.note-cell[open] > summary::after { content: " ▴"; }

/* Response filters: plain links, no script needed. */
.response-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 0.5rem;
}

.response-filter a {
    font-size: 0.8rem;
    font-family: var(--head-font);
    font-weight: 700;
    text-decoration: none;
    color: var(--accent-green);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
}

.response-filter a.is-active {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #ffffff;
}

@media (max-width: 640px) {
    .admin-modal-backdrop { padding: 0; align-items: flex-end; }
    .admin-modal {
        max-width: none;
        border-radius: var(--portal-radius) var(--portal-radius) 0 0;
        padding: 1.25rem;
    }
    .admin-modal__facts { grid-template-columns: 1fr; gap: 0 0; }
    .admin-modal__facts dt { padding-top: 0.6rem; }
    .admin-modal__section .btn-row { flex-direction: column; align-items: stretch; }
    .admin-modal__section .btn-row > * { width: 100%; text-align: center; }
}
