/* LoanPool by Vantage LMS: the board, the lender's own rows and the form
 * (js-lms/loanpool_shared.js), and the public page around them (loanpool.html).
 * Built on the --vantage-* tokens in brand.css so it follows whichever theme the
 * page is on, in the staff application, the external workspace and the public
 * page alike. Semantic colour only: green for live, amber for lapsed, red for an
 * error; everything else is neutral. */

.lp {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    gap: 44px;
    max-width: 1080px;
    font-family: var(--vantage-font-body);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--vantage-text);
}
.lp-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lp-head {
    display: flex; align-items: baseline; justify-content: space-between;
    flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px;
}
.lp-h {
    margin: 0; font-family: var(--vantage-font-heading); font-size: 18px; font-weight: 600;
    line-height: 1.25; letter-spacing: -0.01em; color: var(--vantage-text);
}
.lp-h3 {
    margin: 0 0 14px; font-family: var(--vantage-font-heading); font-size: 15px; font-weight: 600;
    line-height: 1.3; letter-spacing: -0.005em;
}
.lp-asat { margin: 0; font-size: 12.5px; color: var(--vantage-text-2); font-variant-numeric: tabular-nums; }

/* Filters and form fields */
.lp-filters {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.lp-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.lp-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lp-field[hidden] { display: none; }
.lp-field > label, .lp-label { font-size: 12px; color: var(--vantage-text-2); }
.lp-input {
    box-sizing: border-box; width: 100%; min-height: 40px; padding: 0 10px;
    background: var(--vantage-surface); color: var(--vantage-text);
    border: 1px solid var(--vantage-line); border-radius: 8px;
    font: inherit; font-size: 13.5px;
    transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lp-input:hover { border-color: var(--vantage-text-3); }
.lp-input:focus-visible, .lp-btn:focus-visible { outline: 2px solid var(--vantage-accent); outline-offset: 2px; }
.lp-input[aria-invalid="true"] { border-color: var(--lms-danger-ink); }
.lp-unit { position: relative; }
.lp-unit .lp-input { padding-right: 78px; font-variant-numeric: tabular-nums; }
.lp-unit > span {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-size: 12px; color: var(--vantage-text-2); pointer-events: none;
}
.lp-err { display: block; min-height: 0; font-size: 12px; color: var(--lms-danger-ink); }
.lp-err:empty { display: none; }
.lp-derived { display: flex; align-items: center; min-height: 40px; }

/* Buttons: one filled, one quiet. */
.lp-btn {
    min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px;
    background: var(--vantage-accent); color: var(--vantage-bg);
    font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1), background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lp-btn:hover { opacity: 0.88; }
.lp-btn-quiet { background: transparent; color: var(--vantage-text); }
.lp-btn-quiet:hover { opacity: 1; background: var(--vantage-fill-2); }
.lp-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.lp-btn:disabled:hover { opacity: 0.45; background: inherit; }
.lp-btn-quiet:disabled:hover { background: transparent; }

/* The table. Dense data keeps its hairlines. */
.lp-table-wrap { overflow-x: auto; }
.lp-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lp-table th {
    padding: 8px 14px 8px 0; text-align: left; font-size: 12px; font-weight: 500;
    color: var(--vantage-text-2); border-bottom: 1px solid var(--vantage-line);
    white-space: nowrap;
}
.lp-table td { padding: 13px 14px 13px 0; border-bottom: 1px solid var(--vantage-line-2); vertical-align: middle; }
.lp-table tbody tr { transition: background-color 120ms cubic-bezier(0.4, 0, 0.2, 1); }
.lp-table tbody tr:hover { background: var(--vantage-fill); }
.lp-num { text-align: right; padding-right: 18px !important; white-space: nowrap; }
.lp-table th.lp-num { text-align: right; }
.lp-rate { font-weight: 600; color: var(--vantage-text); }
.lp-actions { white-space: nowrap; text-align: right; }
.lp-tag {
    display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
    background: var(--vantage-fill-2); color: var(--vantage-text); font-size: 12px; font-weight: 400;
    white-space: nowrap;
}
.lp-tag-reg { font-weight: 700; }
.lp-live { color: var(--lms-success-ink); font-weight: 500; }
.lp-lapsed { color: var(--lms-warning-ink); font-weight: 600; }

/* Empty, error and notice states. */
.lp-state {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 28px 0; border-top: 1px solid var(--vantage-line-2);
}
.lp-state strong { font-size: 14px; font-weight: 600; }
.lp-state span { color: var(--vantage-text-2); }
.lp-state-error { flex-direction: row; align-items: center; gap: 12px; color: var(--lms-danger-ink); }
.lp-state-error span { color: inherit; }
.lp-note { margin: 0 0 12px; color: var(--lms-warning-ink); font-weight: 500; }
.lp-msg { margin: 0 0 10px; color: var(--vantage-text-2); }
.lp-msg:empty { margin: 0; }
.lp-msg-error { color: var(--lms-danger-ink); }

/* The form sits under the lender's own rows. */
.lp-form { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--vantage-line-2); }
.lp-form-err { margin: 12px 0 0; }
.lp-form-actions { display: flex; gap: 8px; margin-top: 18px; }

/* Loading: skeleton rows. */
.lp-skel {
    height: 44px; margin-bottom: 8px; border-radius: 8px; background: var(--vantage-fill);
    animation: lp-pulse 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes lp-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .lp-skel { animation: none; }
    .lp-input, .lp-btn, .lp-table tbody tr { transition: none; }
}

/* A touch screen gets 44px targets. */
@media (pointer: coarse) {
    .lp-input, .lp-btn { min-height: 44px; }
}

/* A phone: each row becomes a small block of labelled pairs, so nothing scrolls sideways. */
@media (max-width: 640px) {
    .lp { gap: 36px; }
    .lp-table-wrap { overflow-x: visible; }
    .lp-table thead {
        position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    }
    .lp-table, .lp-table tbody { display: block; }
    .lp-table tr {
        display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
        padding: 16px 0; border-bottom: 1px solid var(--vantage-line-2);
    }
    .lp-table td { display: block; padding: 0; border: 0; text-align: left !important; }
    .lp-table td::before {
        content: attr(data-label); display: block; margin-bottom: 2px;
        font-size: 11.5px; color: var(--vantage-text-2); font-weight: 400;
    }
    .lp-table td.lp-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
    .lp-table td.lp-actions::before { display: none; }
    .lp-state-error { flex-direction: column; align-items: flex-start; }
    /* "Sort by" has the longest option text, so it takes the full row. */
    .lp-filters .lp-field:last-child { grid-column: 1 / -1; }
}

/* ─── The public page (loanpool.html) ──────────────────────────────────────
 * Light only, bright and open: a white page, a large quiet headline, generous
 * rows. Its own tokens, scoped to .lpp, so the staff screen and the workspace
 * page (which share .lp-*) keep the look of the application. The house neutrals
 * are kept (near-black ink, no coloured accent); the space does the work. */
.lpp {
    --vantage-bg: #ffffff;
    --vantage-surface: #ffffff;
    --vantage-text: #101418;
    --vantage-text-2: #4b555e;
    --vantage-text-3: #5a646d;
    --vantage-line: rgba(16, 20, 24, 0.16);
    --vantage-line-2: rgba(16, 20, 24, 0.08);
    --vantage-fill: rgba(16, 20, 24, 0.035);
    --vantage-fill-2: rgba(16, 20, 24, 0.07);
    --vantage-accent: #101418;
    min-height: 100vh; display: flex; flex-direction: column;
    background: #ffffff; color: var(--vantage-text);
    -webkit-font-smoothing: antialiased;
}
html:has(.lpp) { background: #ffffff; color-scheme: light; }
.lpp-wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 64px); box-sizing: border-box; }

.lpp-bar { padding: clamp(20px, 3vw, 32px) 0; }
.lpp-mark { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.lpp-mark:focus-visible { outline: 2px solid var(--vantage-accent); outline-offset: 4px; border-radius: 6px; }
.lpp-mark svg { width: 30px; height: 30px; flex: none; }
.lpp-word { display: flex; flex-direction: column; line-height: 1.1; }
.lpp-word b { font-family: var(--vantage-font-heading); font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.lpp-word span { margin-top: 2px; font-size: 11.5px; color: var(--vantage-text-2); letter-spacing: 0.03em; }

.lpp-main { flex: 1; padding-bottom: clamp(56px, 9vw, 120px); }
.lpp-intro { padding: clamp(28px, 6vw, 72px) 0 clamp(32px, 5vw, 56px); }
.lpp-title {
    margin: 0 0 clamp(14px, 2vw, 22px); max-width: 18ch;
    font-family: var(--vantage-font-heading); font-size: clamp(36px, 6.4vw, 64px);
    font-weight: 600; line-height: 1.02; letter-spacing: -0.04em;
}
.lpp-sub { margin: 0; max-width: 54ch; font-size: clamp(16px, 2vw, 19px); line-height: 1.55; color: var(--vantage-text-2); }

/* The board, given room. */
.lpp .lp { max-width: none; margin-top: 0; gap: 0; font-size: 14.5px; }
.lpp .lp-head { margin-bottom: 20px; }
.lpp .lp-h { font-size: 22px; letter-spacing: -0.02em; }
.lpp .lp-asat { font-size: 13.5px; }
.lpp .lp-filters {
    gap: 14px; margin-bottom: 8px; padding: clamp(16px, 2.4vw, 24px);
    background: var(--vantage-fill); border-radius: 18px;
}
.lpp .lp-field > label { font-size: 12.5px; font-weight: 500; }
.lpp .lp-input {
    min-height: 46px; padding: 0 14px; border: 0; border-radius: 12px; background: #ffffff;
    box-shadow: 0 0 0 1px var(--vantage-line-2), 0 1px 2px rgba(16, 20, 24, 0.06);
    font-size: 14.5px;
}
.lpp .lp-input:hover { box-shadow: 0 0 0 1px var(--vantage-line), 0 1px 3px rgba(16, 20, 24, 0.08); }
.lp-filtered { margin: 6px 0 0; min-height: 0; }
.lp-filtered[hidden] { display: none; }
.lp-filtered .lp-btn { padding-left: 0; padding-right: 8px; min-height: 40px; text-decoration: underline; text-underline-offset: 3px; }
.lp-filtered .lp-btn:hover { background: transparent; opacity: 0.7; }

.lpp .lp-table th { padding: 16px 20px 14px 0; border-bottom: 1px solid var(--vantage-line-2); font-size: 12.5px; }
.lpp .lp-table td { padding: 24px 20px 24px 0; border-bottom: 1px solid var(--vantage-line-2); }
.lpp .lp-table tbody tr:hover { background: var(--vantage-fill); }
.lpp .lp-num { padding-right: 22px !important; }
.lpp .lp-rate { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.lpp .lp-tag { padding: 4px 11px; border-radius: 999px; font-size: 12.5px; }
.lpp .lp-state { padding: 56px 0; border-top: 0; align-items: flex-start; }
.lpp .lp-state strong { font-size: 18px; letter-spacing: -0.01em; }
.lpp .lp-state span { font-size: 15px; }

.lpp-foot { padding: clamp(32px, 5vw, 56px) 0 clamp(36px, 6vw, 64px); background: var(--vantage-fill); font-size: 12.5px; line-height: 1.65; color: var(--vantage-text-2); }
.lpp-foot p { max-width: 86ch; margin: 0 0 10px; }
.lpp-foot p:last-child { margin: 0; }

@media (max-width: 640px) {
    /* The stacked cells carry no rules of their own (the desktop rows' rules would otherwise win). */
    .lpp .lp-table td { padding: 0; border-bottom: 0; }
    .lpp .lp-table tr { padding: 22px 0; gap: 14px 18px; }
    .lpp .lp-rate { font-size: 22px; }
    .lpp .lp-filters { border-radius: 16px; }
}
