:root {
    --primary-navy: #0A2342;
    --primary-mustard: #C79B28;
    --accent-gold: #D4AF37;
    --bg-light: #F8FAFC;
    --bg-white: #FFFFFF;
    --bg-body: #FFFFFF;
    --text-dark: #0F172A;
    --text-slate: #334155;
    --text-muted: #64748B;
    --status-success: #10B981;
    --status-warning: #EF4444;
    --status-active: #475569;
    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --sidebar-rail: 68px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-dark);
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Modern White Theme */
.sidebar {
    width: 250px;
    background-color: #FFFFFF;
    color: var(--text-slate);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    box-shadow: 1px 0 3px rgba(15, 23, 42, 0.02);
}

.sidebar-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.logo-img-icon {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.logo-img-full {
    height: 36px;
    width: auto;
}

.logo-img-collapsed {
    height: 36px;
    width: 36px;
    display: none;
}

.brand-text {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--primary-navy);
    letter-spacing: -0.02em;
}

.brand-cash {
    background-color: var(--primary-mustard);
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 2px;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    flex: 1;
}

.nav-item {
    margin: 3px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-slate);
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 12px;
    font-weight: 500;
    font-size: 0.92rem;
    border-radius: 8px;
}

.nav-link:hover {
    background-color: #F1F5F9;
    color: var(--primary-navy);
}

.nav-link.active {
    background-color: rgba(199, 155, 40, 0.12);
    color: var(--primary-navy);
    font-weight: 600;
    border-left: 3px solid var(--primary-mustard);
}

.nav-link i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.nav-link.active i {
    color: var(--primary-mustard);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
    background: #FFFFFF;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - 250px);
}

.top-bar {
    background-color: var(--bg-white);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background-color: var(--status-warning);
    border-radius: 50%;
    border: 2px solid white;
}

.user-profile {
    width: 32px;
    height: 32px;
    background-color: var(--bg-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.content-wrapper {
    padding: 32px;
    /* Wide enough for the loan list once the sidebar is a rail. */
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Dashboard Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background-color: var(--bg-white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 140px;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.metric-title {
    color: var(--primary-navy);
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0;
}

.metric-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

/* Dashboard Panels */
.panels-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.panel {
    background-color: var(--bg-white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    margin-bottom: 20px;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--bg-light);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

tr:nth-child(even) {
    background-color: #FAFAFA;
}

/* Status Badges */
.status-text {
    font-weight: 600;
}

.status-paid {
    color: var(--status-success);
}

.status-overdue {
    color: var(--status-warning);
}

.status-active {
    color: var(--status-active);
}

/* Utilities */
.text-mustard {
    color: var(--primary-mustard);
}

.text-red {
    color: var(--status-warning);
}

.text-green {
    color: var(--status-success);
}

@media (max-width: 1024px) {
    .panels-grid {
        grid-template-columns: 1fr;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.5;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-navy);
    color: white;
}

.btn-primary:hover {
    background-color: #1a3b66;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    border-color: var(--border-color);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: var(--bg-light);
    border-color: #cbd5e0;
}

.btn-danger {
    background-color: var(--status-warning);
    color: white;
}

.btn-danger:hover {
    background-color: #e53e3e;
}

.btn-success {
    background-color: var(--status-success);
    color: white;
}

.btn-success:hover {
    background-color: #38a169;
}

.btn-mustard {
    background-color: var(--primary-mustard);
    color: white;
}

.btn-mustard:hover {
    background-color: #b0861e;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-navy);
    box-shadow: 0 0 0 3px rgba(10, 35, 66, 0.1);
}

/* Utilities */
.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-6 {
    margin-bottom: 24px;
}

.text-right {
    text-align: right;
}

.w-full {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-active {
    background-color: #E2E8F0;
    color: var(--status-active);
}

.badge-overdue {
    background-color: #FED7D7;
    color: var(--status-warning);
}

.badge-paid {
    background-color: #C6F6D5;
    color: var(--status-success);
}
.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Loan Management Dashboard
   ========================================================================== */

.dash-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.dash-hero-title {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--primary-navy);
}

.dash-hero-subtitle {
    margin: 4px 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.dash-hero-capital {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: right;
}

.dash-hero-capital-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.dash-hero-capital-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--status-success);
    line-height: 1.15;
}

.dash-hero-capital-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: var(--bg-white);
    box-shadow: var(--shadow-sm);
    color: var(--primary-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Compact stat cards - a denser variant of .metric-card for the 7-up row */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background-color: var(--bg-white);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

a.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.stat-body {
    min-width: 0;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 3px 0;
    line-height: 1.2;
}

.stat-note {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* The currency is stated once per figure rather than on every table cell */
.stat-unit {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-left: 4px;
    vertical-align: 0.35em;
}

/* Filter bar */
.dash-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dash-search {
    position: relative;
    flex: 1 1 260px;
    max-width: 340px;
}

.dash-search i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.dash-search input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-white);
    font-family: var(--font-family);
    font-size: 0.875rem;
}

.dash-filters select {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-white);
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-dark);
    cursor: pointer;
}

.dash-filters .btn {
    padding: 9px 16px;
    font-size: 0.875rem;
    border-radius: 8px;
}

.dash-clear {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.dash-new-loan {
    margin-left: auto;
}

/* Loan list table - denser than the default table for 15 columns */
.loan-table th,
.loan-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
}

.loan-table th {
    background-color: var(--primary-navy);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: none;
    position: sticky;
    top: 0;
}

.loan-table th:first-child {
    border-top-left-radius: 8px;
}

.loan-table th:last-child {
    border-top-right-radius: 8px;
}

.loan-table .num {
    text-align: right;
}

.loan-table tbody tr:hover {
    background-color: #F1F5FB;
}

.loan-table .muted {
    color: var(--text-muted);
}

.loan-table .days-remaining {
    color: #3182CE;
}

.loan-table-total td {
    background-color: var(--bg-light);
    font-weight: 700;
    color: var(--primary-navy);
    border-top: 2px solid var(--border-color);
    border-bottom: none;
}

/* Risk score and status pills */
.risk-pill {
    display: inline-block;
    min-width: 38px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}

.risk-low {
    background-color: #DEF7EC;
    color: #046C4E;
}

.risk-medium {
    background-color: #FDF6B2;
    color: #8E5A00;
}

.risk-high {
    background-color: #FDE2E1;
    color: #C81E1E;
}

.status-pill {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill-paid {
    background-color: #DEF7EC;
    color: #046C4E;
}

.status-pill-active {
    background-color: #E1EFFE;
    color: #1A56DB;
}

.status-pill-overdue {
    background-color: #FDE2E1;
    color: #C81E1E;
}

.status-pill-defaulted {
    background-color: #E5E7EB;
    color: var(--primary-navy);
}

/* Legend row */
.dash-legends {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.dash-legends .panel {
    padding: 18px 20px;
}

.legend-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary-navy);
    margin-bottom: 12px;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-items>span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.legend-notes {
    margin: 0;
    padding-left: 18px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.7;
}

/* All seven portfolio figures read as one row once there is room for them. */
@media (min-width: 1250px) {
    .stat-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .dash-new-loan {
        margin-left: 0;
    }

    .dash-hero-capital {
        text-align: left;
    }

    /* Mobile off-canvas drawer sidebar */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 270px !important;
        height: 100vh;
        height: 100dvh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 0 30px rgba(10, 35, 66, 0.25);
    }

    body.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Keep nav-labels and brand-text visible inside mobile slide-out drawer */
    body.mobile-sidebar-open .sidebar .nav-label,
    body.mobile-sidebar-open .sidebar .brand-text {
        display: inline !important;
    }

    body.mobile-sidebar-open .sidebar .nav-link {
        padding: 10px 16px;
        justify-content: flex-start;
        gap: 12px;
    }

    body.mobile-sidebar-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(10, 35, 66, 0.45);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 1040;
    }

    /* Main content takes full screen width on mobile */
    .main-content,
    .sidebar-collapsed .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .top-bar {
        padding: 0 16px;
        height: 56px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .content-wrapper {
        padding: 16px 12px;
    }

    /* Touch targets and preventing iOS auto-zoom */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Smooth table horizontal scrolling on phones */
    .table-container,
    .table-responsive,
    .panel {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .top-actions {
        gap: 12px;
    }
}

@media (max-width: 520px) {
    .top-actions a.btn-secondary {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
    }

    .stat-card {
        padding: 16px 14px;
    }
}

/* ==========================================================================
   Collapsible sidebar
   The rail is the default so wide tables (the loan list) get the full width.
   `body.sidebar-collapsed` is set server-side and toggled from the top bar.
   ========================================================================== */

.sidebar,
.main-content {
    transition: width 0.2s ease, margin-left 0.2s ease;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-rail, 64px);
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-rail, 64px);
    width: calc(100% - var(--sidebar-rail, 64px));
}

/* Icons centre themselves once the labels are gone. */
.sidebar-collapsed .nav-label,
.sidebar-collapsed .brand-text {
    display: none;
}

.sidebar-collapsed .nav-link {
    padding: 12px 0;
    justify-content: center;
    gap: 0;
}

.sidebar-collapsed .nav-link i {
    width: auto;
    font-size: 1.05rem;
}

/* The external-link and badge affordances only make sense beside a label. */
.sidebar-collapsed .nav-link .fa-arrow-up-right-from-square {
    display: none;
}

.sidebar-collapsed .sidebar-header {
    padding: 20px 0;
    justify-content: center;
}

.sidebar-collapsed .sidebar-footer {
    padding: 16px 0;
}

.sidebar-collapsed .nav-menu {
    margin: 12px 0;
}

/* The official logo icon stands in for the wordmark on the rail */
.sidebar-collapsed .sidebar-header::after {
    display: none;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.05rem;
    padding: 8px;
    border-radius: 8px;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-toggle:hover {
    background-color: var(--bg-light);
    color: var(--primary-navy);
}

/* ==========================================================================
   Horizontally pannable loan list
   The table is far wider than the viewport, so it gets an explicit scrollbar,
   arrow buttons, drag-panning and edge shadows, and keeps the identifying
   first two columns pinned while the money columns slide past.
   ========================================================================== */

.loan-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.table-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-nav-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.table-nav-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-white);
    color: var(--primary-navy);
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, opacity 0.15s;
}

.table-nav-btn:hover:not(:disabled) {
    background-color: var(--bg-light);
}

.table-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Edge shadows appear only on the side that still has hidden columns. */
.slider {
    position: relative;
}

.slider::before,
.slider::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

.slider::before {
    left: 0;
    background: linear-gradient(to right, rgba(10, 35, 66, 0.13), transparent);
}

.slider::after {
    right: 0;
    background: linear-gradient(to left, rgba(10, 35, 66, 0.13), transparent);
}

.slider.can-scroll-left::before,
.slider.can-scroll-right::after {
    opacity: 1;
}

.slider-track {
    /* The property that makes a track actually pan; .table-container carries
       its own copy for tables used outside a slider. */
    overflow-x: auto;
    cursor: grab;
    scrollbar-width: thin;
    scrollbar-color: #C3CCD8 transparent;
    overscroll-behavior-x: contain;
}

.slider-track.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.slider-track::-webkit-scrollbar {
    height: 10px;
}

.slider-track::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 999px;
}

.slider-track::-webkit-scrollbar-thumb {
    background: #C3CCD8;
    border-radius: 999px;
}

.slider-track::-webkit-scrollbar-thumb:hover {
    background: #A9B5C4;
}

/* Row backgrounds must be opaque for the pinned columns to sit on top of the
   sliding ones, so they are declared on the row and inherited by the cells. */
.loan-table tbody tr {
    background-color: var(--bg-white);
}

.loan-table tbody tr:nth-child(even) {
    background-color: #FAFAFA;
}

.loan-table tbody tr:hover {
    background-color: #F1F5FB;
}

/* Pin "#" and "Client Name" so a row stays identifiable while panning. */
.loan-table thead th:nth-child(1),
.loan-table tbody td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 46px;
    min-width: 46px;
}

.loan-table thead th:nth-child(2),
.loan-table tbody td:nth-child(2) {
    position: sticky;
    left: 46px;
    z-index: 2;
    min-width: 130px;
    box-shadow: 1px 0 0 var(--border-color);
}

.loan-table tbody td:nth-child(1),
.loan-table tbody td:nth-child(2) {
    background-color: inherit;
}

.loan-table thead th:nth-child(1),
.loan-table thead th:nth-child(2) {
    background-color: var(--primary-navy);
    z-index: 4;
}

/* The footer's "TOTAL" cell spans both pinned columns, so it pins as one. */
.loan-table tfoot td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--bg-light);
    box-shadow: 1px 0 0 var(--border-color);
}

@media (max-width: 700px) {
    .table-nav-hint {
        display: none;
    }
}

/* ==========================================================================
   Slider rows: metric cards and the guides row
   Both previously wrapped onto extra lines. They now stay on one line and
   pan sideways, growing to fill the width whenever they do fit.
   ========================================================================== */

.stat-grid.slider-track,
.dash-legends.slider-track {
    display: flex;
    /* Vertical padding keeps the cards' drop shadows from being clipped by
       the horizontal overflow. */
    padding: 5px 2px;
    margin-bottom: 19px;
    scroll-behavior: smooth;
}

.stat-grid.slider-track > * {
    flex: 1 0 170px;
    min-width: 170px;
}

.dash-legends.slider-track {
    margin-top: 19px;
    margin-bottom: 0;
}

.dash-legends.slider-track > * {
    flex: 1 0 280px;
    min-width: 280px;
}

/* The fixed 7-column rule is what the flex basis now handles. */
@media (min-width: 1250px) {
    .stat-grid.slider-track {
        grid-template-columns: none;
    }
}

/* Floating arrows for sliders that have no header to host them. */
.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    color: var(--primary-navy);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background-color 0.15s;
}

.slider-arrow-left {
    left: -6px;
}

.slider-arrow-right {
    right: -6px;
}

/* Only offer an arrow when there is somewhere to go. */
.slider.can-scroll-left .slider-arrow-left,
.slider.can-scroll-right .slider-arrow-right {
    opacity: 1;
    pointer-events: auto;
}

.slider-arrow:hover {
    background-color: var(--bg-light);
}
