/* ── Variables ── */
:root {
    --brand-dark: #1a2332;
    --brand-mid: #243447;
    --brand-accent: #3b82f6;
    --brand-accent-light: #60a5fa;
    --surface: #f0f4f8;
    --surface-card: #ffffff;
    --text-primary: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --table-header: #2d3f55;
    --row-hover: #f1f5fb;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* ── Reset ── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--surface);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ── Top bar ── */
.topbar {
    background: var(--brand-dark);
    padding: 0.75rem 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.topbar-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.topbar-brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    padding-right: 2rem;
}

.topbar-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}


.brand-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

/* ── Stat card ── */
.topbar-stats {
    flex-shrink: 0;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--brand-accent);
    border-radius: 10px;
    padding: 0.4rem 1.2rem;
    min-width: 80px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

/* ── Table section ── */
.table-section {
    margin: 1.5rem 1.5rem;
    background: var(--surface-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ── Toolbar ── */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--table-header);
    padding: 0.9rem 1.25rem;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-wrapper {
    position: relative;
    flex-shrink: 0;
}

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

.search-wrapper .form-control {
    padding-left: 2rem;
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 200px;
}

.search-wrapper .form-control:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.table-title {
    flex: 1;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    letter-spacing: 0.03em;
}

.table-count {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
    font-weight: 500;
}

/* ── Table ── */
.table-responsive {
    overflow-x: auto;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.clients-table {
    margin: 0;
    font-size: 0.85rem;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.clients-table thead th,
.clients-table tbody td {
    border-right: 1px solid rgba(226, 232, 240, 0.5);
}

.clients-table thead th:last-child,
.clients-table tbody td:last-child {
    border-right: none;
}

.clients-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
    white-space: normal;
    max-width: 150px;
    text-align: center;
    vertical-align: middle;
    z-index: 1;
}

.clients-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}

.clients-table tbody tr:last-child {
    border-bottom: none;
}

.clients-table tbody tr:hover {
    background: var(--row-hover);
}

.clients-table td {
    padding: 0.6rem 1rem;
    vertical-align: middle;
    white-space: nowrap;
    color: var(--text-primary);
}

/* ── Cell styles ── */
.loan-number {
    font-weight: 700;
    color: var(--brand-accent);
    font-variant-numeric: tabular-nums;
}

.client-name {
    font-weight: 600;
}

.days-cell {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--text-muted);
}

.badge-portfolio {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    letter-spacing: 0.04em;
}

.badge-term {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
}

.term-mo {
    background: #fef3c7;
    color: #92400e;
}

.term-we {
    background: #f3e8ff;
    color: #6b21a8;
}

.coborrower-yes {
    color: #16a34a;
    font-weight: 600;
    font-size: 0.82rem;
}

.coborrower-no {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ── Active Filters Bar ── */
.active-filters-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: #f1f5fb;
    border-bottom: 1px solid var(--border);
}

.active-filters-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.25rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--brand-accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    white-space: nowrap;
}

.filter-tag-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.filter-tag-remove:hover {
    color: #fff;
}

.filter-tag-clear-all {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    cursor: pointer;
    margin-left: 0.25rem;
}

.filter-tag-clear-all:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* ── Filter Rows ── */
.filter-row {
    margin-bottom: 1rem;
}

.filter-row-inner {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr auto;
    gap: 0.5rem;
    align-items: flex-start;
}

.filter-value {
    display: flex;
    gap: 0.5rem;
}

.filter-input {
    flex: 1;
}

.btn-delete-filter {
    padding: 0.375rem 0.75rem;
}

/* ── Offcanvas filter ── */
#filterOffcanvas {
    width: 650px !important;
}

.multi-select-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    background: #f9fafb;
}

.form-check-sm {
    margin: 0;
    padding: 0.25rem 0;
}

.form-check-sm .form-check-input {
    margin-top: 0.15rem;
}

.form-check-sm .form-check-label {
    font-size: 0.85rem;
    margin-bottom: 0;
    margin-left: 0.3rem;
    cursor: pointer;
}

/* ── Sticky first column ── */
.col-sticky {
    position: sticky;
    left: 0;
    background: #ffffff;
    z-index: 2;
}

.clients-table thead .col-sticky {
    background: #f8fafc;
    z-index: 3;
}

.clients-table tbody tr:hover .col-sticky {
    background: var(--row-hover);
}

/* ── Narrow cell ── */
.col-narrow {
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
}

/* ── Centered cell ── */
.cell-center {
    text-align: center;
}

/* ── Truncated cell ── */
.truncate-cell {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

/* ── Scrollbar ── */
.table-responsive::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--border);
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

