:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --ink: #172033;
    --muted: #667085;
    --line: #dde3ea;
    --panel: #ffffff;
    --blue: #22577a;
    --blue-2: #2f80a8;
    --green: #147a4b;
    --green-bg: #e7f5ee;
    --red: #b42318;
    --red-bg: #fff0ee;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(rgba(246, 247, 249, 0.92), rgba(246, 247, 249, 0.94)),
        url("finance-background.jpg") center / cover fixed;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
    width: min(1680px, calc(100vw - 16px));
    margin: 0 auto;
    padding: 12px 0 28px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #14344b, #276f6d);
    color: #fff;
    border-radius: 8px;
}

.eyebrow {
    margin: 0 0 4px;
    color: #cce7ea;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 17px;
}

.refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 6px;
    background: #fff;
    color: #14344b;
    font-weight: 700;
    text-decoration: none;
}

.header-actions { display: flex; gap: 8px; }
.loan-hero { padding: 26px 28px; background: linear-gradient(135deg, #12344a, #1f6a65); }
.hero-copy { max-width: 720px; margin: 8px 0 0; color: #d5e9e7; }
.loan-nav { position: sticky; top: 0; z-index: 4; display: flex; gap: 6px; margin: 10px 0; padding: 6px; background: rgba(246,247,249,.95); border: 1px solid var(--line); border-radius: 8px; backdrop-filter: blur(8px); }
.loan-nav a { padding: 8px 12px; color: var(--ink); font-size: 13px; font-weight: 800; text-decoration: none; border-radius: 5px; }
.loan-nav a:hover { background: #fff; color: var(--blue); }
.loan-nav a.active { background: #fff; color: var(--blue); box-shadow: 0 1px 4px rgba(16,24,40,.09); }
.loan-kpis { grid-template-columns: repeat(4, minmax(0,1fr)); }
.loan-kpis div { min-height: 98px; border-top: 3px solid #2d7670; }
.loan-kpis strong { font-size: 23px; letter-spacing: -.03em; }
.panel-title, .bar-legend, .check-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.panel-title span { color: var(--muted); font-size: 12px; font-weight: 700; }
.bar { height: 13px; margin: 22px 0 12px; overflow: hidden; border-radius: 99px; background: #e6a35c; }
.bar i { display: block; height: 100%; background: #236a66; }
.bar-legend { font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; }.dot.bv{background:#236a66}.dot.private{background:#e6a35c}
.check-row { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.check-row:last-child { border: 0; }
.search { width: 260px; background: #fff; }
.add-panel { margin-bottom: 10px; }
.loan-edit-form { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; margin-top: 14px; }
.allocation-form { display: grid; grid-template-columns: 1.2fr 2fr 1fr 1fr auto; gap: 10px; margin-top: 14px; }
.span-2 { grid-column: span 2; }
.edit-table { min-width: 1680px; }
.compact-table table { min-width: 880px; }
.edit-table input, .edit-table select, .edit-table textarea, .compact-table input, .compact-table select { min-height: 32px; padding: 5px 7px; font-size: 12px; border-color: transparent; background: transparent; }
.edit-table input:focus, .edit-table select:focus, .edit-table textarea:focus, .compact-table input:focus, .compact-table select:focus { background: #fff; border-color: var(--blue-2); outline: none; }
.edit-table textarea { min-width: 230px; resize: vertical; }
.edit-table button, .compact-table button { min-height: 30px; padding: 0 10px; font-size: 11px; }
.rate-field { max-width: 74px; }
.share-cell { position: relative; min-width: 190px; height: 24px; background: #eef2f4; border-radius: 4px; overflow: hidden; }
.share-cell i { position: absolute; inset: 0 auto 0 0; background: #cae3df; }.share-cell span { position: relative; display: block; padding: 4px 7px; font-weight: 800; }
.loan-footer { padding: 26px 4px 8px; color: var(--muted); font-size: 12px; }
.signed-in { align-self: center; color: #d5e9e7; font-size: 13px; font-weight: 800; }
.section-actions, .detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.edit-trigger { min-height: 38px; padding: 0 14px; background: var(--blue); white-space: nowrap; }
.edit-modal { width: min(720px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 24px 80px rgba(16,24,40,.28); }
.edit-modal::backdrop { background: rgba(12,24,36,.58); backdrop-filter: blur(3px); }
.modal-form { padding: 22px; }.modal-head,.modal-actions{display:flex;align-items:center;justify-content:space-between;gap:14px}.modal-head h2{font-size:23px}.modal-close{min-height:36px;width:36px;background:#eef2f4;color:var(--ink);font-size:24px}.modal-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px;margin:22px 0}.modal-grid textarea{width:100%;padding:9px 10px;border:1px solid var(--line);border-radius:6px;font:inherit;resize:vertical}.modal-actions{justify-content:flex-end;border-top:1px solid var(--line);padding-top:16px}.modal-actions button{padding:0 16px}
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(rgba(10,35,53,.70),rgba(12,43,58,.74)),url("finance-background.jpg") center/cover fixed; }
.login-card { width: min(420px,100%); padding: 32px; background:#fff; border:1px solid var(--line); border-radius:14px; box-shadow:0 18px 60px rgba(18,52,74,.14); }.login-card h1{color:var(--ink);font-size:28px}.login-card>p{color:var(--muted);line-height:1.5}.login-form{display:grid;gap:15px;margin-top:24px}.login-form button{min-height:44px}
.back-link, .text-link { display: inline-flex; margin: 10px 0; color: var(--blue); font-weight: 800; text-decoration: none; }
.loan-card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.loan-card { display: block; min-height: 150px; padding: 18px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; transition: transform .15s ease,border-color .15s ease; }
.loan-card:hover { transform: translateY(-2px); border-color: #79a6a1; }
.loan-card h3 { margin: 18px 0 5px; font-size: 18px; }.loan-card>strong{font-size:21px}.loan-card div{display:flex;justify-content:space-between;margin-top:18px;color:var(--muted);font-size:13px;font-weight:700}
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 99px; color: #176047; background: #e5f4ed; font-size: 11px; font-weight: 900; }
.check-row { color: var(--ink); text-decoration: none; }
.clickable-row { cursor: pointer; }.clickable-row:hover{background:#f1f7f6}
.row-toggle { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 30px; padding: 0; color: var(--ink); background: transparent; text-align: left; }
.row-toggle small { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.toggle-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #e8f1f0; color: #1f6a65; font-size: 20px; line-height: 1; transition: transform .15s ease; }
.row-toggle[aria-expanded="true"] .toggle-icon { transform: rotate(90deg); }
.row-open { min-height: 29px; padding: 0 10px; background: #e8f1f0; color: #1f6a65; font-size: 11px; }
.quick-detail-row td { padding: 0; background: #f5f9f8; text-align: left; white-space: normal; }
.quick-detail { padding: 18px 22px 22px 50px; border-top: 1px solid #bad7d3; border-bottom: 1px solid #bad7d3; }
.quick-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.quick-detail-head h3 { margin: 3px 0 0; font-size: 16px; }
.detail-button { display: inline-flex; flex: 0 0 auto; padding: 9px 13px; border-radius: 6px; background: var(--blue); color: #fff; font-weight: 800; text-decoration: none; }
.quick-lenders { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.quick-lender { display: grid; grid-template-columns: minmax(0,1.5fr) 1fr .8fr; gap: 12px; align-items: center; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.quick-lender div span, .quick-lender>span { display: block; color: var(--muted); font-size: 11px; }.quick-lender>strong,.quick-lender>span{text-align:right}
.detail-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 10px; align-items: start; }
.loan-facts { position: sticky; top: 62px; }.loan-facts h2{margin-bottom:14px}.loan-facts dl{margin:0}.loan-facts dl div{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--line)}.loan-facts dt{color:var(--muted)}.loan-facts dd{margin:0;font-weight:800;text-align:right}.loan-facts p{color:var(--muted);line-height:1.5}
.compact-heading { margin-top: 4px; }

.period-tabs {
    display: inline-flex;
    gap: 4px;
    margin: 16px 0 0;
    padding: 4px;
    background: #e8eef4;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.period-tabs a {
    padding: 9px 14px;
    border-radius: 6px;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.period-tabs a.active {
    background: #fff;
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.08);
}

.alert {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--red-bg);
    border: 1px solid #ffb4ab;
    border-radius: 8px;
    color: var(--red);
    font-weight: 700;
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.summary div,
.panel,
.table-wrap,
.exchange-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.summary div {
    padding: 12px;
}

.summary span,
.meta,
.muted,
small {
    color: var(--muted);
}

.summary strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 13px;
    margin-bottom: 16px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 26px 0 12px;
    padding-top: 8px;
}

.section-heading h2 {
    font-size: 24px;
}

.eyebrow.dark {
    color: var(--blue);
}

.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.forms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.trade-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.loan-form {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.wide {
    grid-column: span 2;
}

.trade-panel summary {
    cursor: pointer;
    color: var(--ink);
    font-size: 17px;
    font-weight: 800;
}

.trade-panel summary::marker {
    color: var(--blue);
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

button {
    align-self: end;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.exchange-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.exchange-card {
    padding: 14px;
}

.exchange-card span,
.exchange-card small {
    display: block;
}

.exchange-card strong {
    display: block;
    margin: 6px 0 4px;
    font-size: 20px;
}

.panel {
    padding: 12px;
}

.rank-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
}

.rank-row:last-child {
    border-bottom: 0;
}

.table-wrap {
    margin-bottom: 10px;
    overflow-x: auto;
}

.table-wrap h2 {
    padding: 10px 10px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1180px;
    font-size: 12px;
}

th,
td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #edf3f8;
    color: #344054;
    font-size: 12px;
    text-transform: uppercase;
}

.cell-input {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 12px;
}

.name-input {
    min-width: 145px;
}

.number-input {
    max-width: 110px;
}

.mini-input {
    max-width: 72px;
}

.mini-select {
    max-width: 62px;
    margin-top: 4px;
}

.date-input {
    max-width: 128px;
}

.note-input {
    min-width: 170px;
}

.actions-cell {
    display: flex;
    gap: 4px;
}

.actions-cell button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 11px;
}

.danger-button {
    background: var(--red);
}

.secondary-button {
    background: #667085;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #edf3f8;
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
}

.muted-table {
    opacity: 0.78;
}

td:first-child,
th:first-child {
    text-align: left;
}

tbody tr:hover {
    background: #f9fbfc;
}

.positive {
    color: var(--green);
}

.negative {
    color: var(--red);
}

.warning {
    color: #a15c00;
}

.notice {
    color: var(--blue-2);
}

.neutral {
    color: var(--muted);
}

td.positive,
td.negative,
td.warning,
td.notice {
    font-weight: 700;
}

.note-cell {
    max-width: 320px;
    white-space: normal;
    text-align: left;
}

small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
}

@media (max-width: 860px) {
    .page {
        width: min(100vw - 20px, 1380px);
        padding-top: 10px;
    }

    .header,
    .summary,
    .split,
    .forms,
    .trade-form,
    .loan-form,
    .exchange-grid {
        grid-template-columns: 1fr;
    }

    .header {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: 24px;
    }

    .loan-kpis, .loan-edit-form, .allocation-form { grid-template-columns: 1fr; }
    .loan-card-grid, .detail-layout { grid-template-columns: 1fr; }
    .quick-lenders { grid-template-columns: 1fr; }
    .quick-detail { padding-left: 14px; }
    .quick-detail-head { align-items: flex-start; flex-direction: column; }
    .section-actions, .detail-toolbar { width: 100%; align-items: stretch; flex-direction: column; }
    .modal-grid { grid-template-columns: 1fr; }
    .loan-facts { position: static; }
    .span-2 { grid-column: auto; }
    .loan-nav { overflow-x: auto; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .search { width: 100%; }
}
