/* 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; }
}

/* ─── The public page (loanpool.html) ────────────────────────────────────── */
.lpp-main .lp { margin-top: 0; }
.lpp { min-height: 100vh; display: flex; flex-direction: column; background: var(--vantage-bg); color: var(--vantage-text); }
.lpp-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px clamp(16px, 4vw, 40px);
}
.lpp-mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.lpp-mark svg { width: 26px; height: 26px; flex: none; }
.lpp-word { display: flex; flex-direction: column; line-height: 1.1; }
.lpp-word b { font-family: var(--vantage-font-heading); font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.lpp-word span { font-size: 11px; color: var(--vantage-text-2); letter-spacing: 0.02em; }
.lpp-main { flex: 1; padding: 20px clamp(16px, 4vw, 40px) 56px; }
.lpp-intro { max-width: 1080px; margin: 0 0 32px; }
.lpp-title {
    margin: 0 0 8px; font-family: var(--vantage-font-heading); font-size: clamp(26px, 4vw, 34px);
    font-weight: 700; line-height: 1.1; letter-spacing: -0.025em;
}
.lpp-sub { margin: 0; max-width: 62ch; font-size: 15px; color: var(--vantage-text-2); }
.lpp-foot {
    padding: 28px clamp(16px, 4vw, 40px) 40px; border-top: 1px solid var(--vantage-line-2);
    font-size: 12px; line-height: 1.6; color: var(--vantage-text-2);
}
.lpp-foot p { max-width: 84ch; margin: 0 0 8px; }
