/* === Base === */
:root {
    --brand: #1a56db;
    --brand-light: #e8effc;
    --surface: #ffffff;
    --surface-alt: #f8f9fb;
    --border: #e5e7eb;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --positive: #059669;
    --negative: #dc2626;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--surface-alt);
    color: var(--text);
    font-size: 0.8rem;
}

/* === Login === */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    width: 320px;
}

/* === Navbar === */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 0.5rem 0;
    z-index: 1030;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--brand), #3b82f6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.navbar-brand {
    font-size: 1.05rem;
    color: var(--text) !important;
}

.nav-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    font-weight: 400;
}

/* === Cards === */
.panel-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
    overflow: hidden;
}

.panel-card .card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
}

.metric-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.metric-card .card-body {
    padding: 0.5rem 0.75rem;
}

.metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.metric-sub {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 0.1rem;
    font-variant-numeric: tabular-nums;
}

/* === Detail Header === */
.detail-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* === Loan List === */
.loan-list {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
    scrollbar-width: thin;
}

.loan-list::-webkit-scrollbar {
    width: 5px;
}

.loan-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.loan-group-header {
    padding: 0.3rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.loan-group-header:hover {
    background: #e8effc;
}

.loan-group-child {
    padding-left: 1.5rem !important;
}

.loan-group-chev {
    font-size: 0.6rem;
    transition: transform 0.15s;
}

.loan-item {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.loan-item:hover {
    background: var(--surface-alt);
}

.loan-item.active {
    background: var(--brand-light);
    border-left: 3px solid var(--brand);
}

.loan-item .borrower {
    font-weight: 600;
    font-size: 0.73rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loan-item .loan-meta {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    display: flex;
    gap: 0.75rem;
}

.loan-item .loan-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* === Tabs === */
.nav-tabs .nav-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    padding: 0.6rem 1rem;
}

.nav-tabs .nav-link.active {
    color: var(--brand);
    border-bottom: 2px solid var(--brand);
    background: transparent;
}

/* === Cashflow Table === */
.cashflow-table {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.cashflow-table thead th {
    background: var(--surface-alt);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    padding: 0.25rem 0.5rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

.cashflow-table td {
    padding: 0.2rem 0.5rem;
    vertical-align: middle;
}

.cashflow-table tfoot td {
    font-weight: 700;
    background: var(--surface-alt);
    border-top: 2px solid var(--border);
    padding: 0.25rem 0.5rem;
}

.cashflow-table tbody tr:hover {
    background: #f0f4ff;
}

.row-maturity {
    background: #fefce8 !important;
}

.row-amort {
    background: #f0fdf4 !important;
}

/* === 10% Test === */
.test-pass {
    border-color: #059669 !important;
    background: #ecfdf5 !important;
}

.test-pass .metric-value {
    color: #059669;
}

.test-fail {
    border-color: #dc2626 !important;
    background: #fef2f2 !important;
}

.test-fail .metric-value {
    color: #dc2626;
}

/* === Tap Highlight === */
.tap-highlight {
    border-color: var(--brand) !important;
    background: var(--brand-light) !important;
}

.tap-highlight .metric-value {
    color: var(--brand);
}

/* === Empty State === */
.empty-icon {
    font-size: 3rem;
    color: var(--text-tertiary);
    opacity: 0.4;
}

/* === Methodology === */
.methodology {
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    max-width: 720px;
}

.methodology h6 {
    color: var(--text);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.methodology h6:first-child {
    margin-top: 0;
}

.methodology ol {
    padding-left: 1.25rem;
}

.methodology li {
    margin-bottom: 0.5rem;
}

/* === Controls Row === */
.control-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.control-input {
    width: 140px;
}

.control-input .form-control {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

#giltSelect {
    font-size: 0.78rem;
    max-width: 480px;
}

/* === Badges === */
.badge {
    font-weight: 500;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
}

/* === Portfolio === */
.pf-council-row {
    background: var(--surface-alt) !important;
}

.pf-council-row:hover {
    background: #e8effc !important;
}

.pf-loan-row {
    font-size: 0.68rem;
}

.pf-loan-row td {
    padding-top: 0.15rem !important;
    padding-bottom: 0.15rem !important;
}

.pf-chevron {
    font-size: 0.7rem;
    transition: transform 0.15s;
}

.pf-inline-override {
    font-size: 0.6rem;
    color: var(--text-tertiary);
}

.pf-ov-input {
    width: 32px;
    padding: 0 2px;
    font-size: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    text-align: center;
    background: var(--surface);
    color: var(--text);
}

.pf-excluded {
    opacity: 0.35;
}

.pf-loan-check {
    cursor: pointer;
}

.pf-ov-input:focus {
    outline: 1px solid var(--brand);
    border-color: var(--brand);
}

/* === Admin/Advisor View === */
body.advisor-mode .admin-only {
    display: none !important;
}

/* Hide dur and fee columns in portfolio table for advisor (10=dur, 11=fee RSX, 12=fee R&T) */
body.advisor-mode #pfTable th:nth-child(10),
body.advisor-mode #pfTable td:nth-child(10),
body.advisor-mode #pfTable th:nth-child(11),
body.advisor-mode #pfTable td:nth-child(11),
body.advisor-mode #pfTable th:nth-child(12),
body.advisor-mode #pfTable td:nth-child(12) {
    display: none !important;
}

/* === Responsive === */
@media (max-width: 991.98px) {
    .loan-list {
        max-height: 300px;
    }
}

/* === Scrollbar for cashflow === */
#tabCashflows .table-responsive {
    max-height: 500px;
    overflow-y: auto;
}
