@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==========================================================================
   CSS Variables / Design System
   ========================================================================== */
:root {
    --bg-color: #0a0e1a;
    --bg-surface: #111827;
    --card-bg: rgba(255, 255, 255, 0.04);
    --card-bg-hover: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.15);

    --primary-accent: #00d4ff;
    --primary-accent-rgb: 0, 212, 255;
    --secondary-accent: #ffb347;
    --secondary-accent-rgb: 255, 179, 71;
    --variable-accent: #a78bfa;
    --variable-accent-rgb: 167, 139, 250;

    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-tiny: #475569;

    --topbar-height: 70px;
    --radius-card: 14px;
    --radius-input: 8px;
    --radius-badge: 20px;
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-glow-primary: 0 0 20px rgba(0, 212, 255, 0.15);
    --shadow-glow-secondary: 0 0 20px rgba(255, 179, 71, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    background-image: 
        radial-gradient(ellipse at 10% 20%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(167, 139, 250, 0.03) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { text-decoration: none; color: var(--primary-accent); }
a:hover { text-decoration: underline; }

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ==========================================================================
   Layout
   ========================================================================== */
/* ==========================================================================
   Top Navigation
   ========================================================================== */
.topbar {
    height: var(--topbar-height);
    background: rgba(10, 14, 26, 0.9);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2.5rem;
    z-index: 100;
    transition: var(--transition);
}

.main-content {
    margin-top: var(--topbar-height);
    padding: 2rem 2.5rem;
    min-height: calc(100vh - var(--topbar-height));
    overflow-x: hidden;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 3rem;
}

.topbar .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #00d4ff, #0088ff);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.topbar .logo-text {
    display: flex;
    flex-direction: column;
    margin-left: -2.25rem;
}

.topbar .logo-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.topbar .logo-subtitle {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-input);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none !important;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--primary-accent);
    background: rgba(0, 212, 255, 0.08);
}

.nav-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-link.active svg {
    opacity: 1;
}

.topbar-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ==========================================================================
   Views
   ========================================================================== */
.view {
    display: none;
    animation: fadeIn 0.35s ease;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

/* Keep borrower detail header always visible */
#view-borrower-detail .view-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-primary);
    padding: 1rem 0 1rem;
    margin-top: -1rem;
}

.view-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.view-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ==========================================================================
   Dashboard Cards
   ========================================================================== */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
    animation: slideUp 0.5s ease backwards;
}

.metric-card:nth-child(1) { animation-delay: 0s; }
.metric-card:nth-child(2) { animation-delay: 0.08s; }
.metric-card:nth-child(3) { animation-delay: 0.16s; }
.metric-card:nth-child(4) { animation-delay: 0.24s; }
.metric-card:nth-child(5) { animation-delay: 0.32s; }
.metric-card:nth-child(6) { animation-delay: 0.40s; }

.metric-card:hover {
    border-color: var(--glass-border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-glass);
}

.metric-card.clickable-card {
    cursor: pointer;
}
.metric-card.clickable-card:hover {
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.15);
}

.metric-card.small {
    padding: 1.25rem;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.metric-card.small .metric-value {
    font-size: 1.25rem;
}

.accent-online { color: var(--primary-accent) !important; }
.accent-offline { color: var(--secondary-accent) !important; }
.accent-variable { color: var(--variable-accent) !important; }

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem 1.5rem;
}

.link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary-accent);
    text-decoration: none !important;
}
.link:hover {
    text-decoration: underline !important;
}

/* ==========================================================================
   Summary Breakdown (Dashboard Right Panel)
   ========================================================================== */
.summary-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.summary-value {
    font-size: 1rem;
    font-weight: 600;
}

.summary-divider {
    height: 1px;
    background: var(--glass-border);
}

.summary-total .summary-label {
    color: var(--text-primary);
    font-weight: 600;
}

.summary-total .summary-value {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-online { background: var(--primary-accent); }
.dot-offline { background: var(--secondary-accent); }
.dot-variable { background: var(--variable-accent); }

/* ==========================================================================
   Borrower Grid & Cards
   ========================================================================== */
.borrower-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.borrower-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    animation: slideUp 0.4s ease backwards;
}

.borrower-card:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 212, 255, 0.2);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), var(--shadow-glow-primary);
}

.borrower-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.borrower-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #00d4ff, #0088ff);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.borrower-card-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: var(--transition);
}

.borrower-card:hover .borrower-card-actions {
    opacity: 1;
}

.borrower-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.borrower-card-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.borrower-card-stats {
    display: flex;
    gap: 1rem;
    margin: 0.75rem 0;
    padding: 0.75rem 0;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.borrower-card-interest {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.interest-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-badge);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
}

.interest-chip.online { color: var(--primary-accent); border-color: rgba(0, 212, 255, 0.2); }
.interest-chip.offline { color: var(--secondary-accent); border-color: rgba(255, 179, 71, 0.2); }

/* ==========================================================================
   Detail Summary Cards
   ========================================================================== */
.detail-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
    gap: 0;
}

.tab {
    background: none;
    border: none;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary-accent);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-accent), #0088ff);
    border-radius: 1px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-wrapper {
    overflow: auto;
    max-height: calc(100vh - 340px);
    padding: 0 0 0.5rem;
    -webkit-overflow-scrolling: touch;
}

/* Share button group */
.btn-group-share {
    display: inline-flex;
    gap: 0.375rem;
}

.btn-success {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #128C7E, #075E54);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.data-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    background: var(--bg-primary, #0a0e1a);
    padding: 0.875rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.825rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: var(--transition);
}

.rep-group-row td {
    background: rgba(255, 255, 255, 0.05) !important;
    font-weight: 600;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.data-table-compact th { padding: 0.625rem 0.875rem; }
.data-table-compact td { padding: 0.5rem 0.875rem; font-size: 0.8rem; }

.text-right { text-align: right; }
.text-small { font-size: 0.75rem; color: var(--text-secondary); max-width: 200px; white-space: normal; }
.text-tiny { font-size: 0.7rem; color: var(--text-muted); }

.col-online { color: var(--primary-accent); }
.col-offline { color: var(--secondary-accent); }
.col-variable { color: var(--variable-accent); }

.tfoot-row td {
    background: rgba(255, 255, 255, 0.03);
    border-top: 2px solid var(--glass-border);
    font-weight: 600;
}

.row-closed td { opacity: 0.45; text-decoration: line-through; }
.row-current td { background: rgba(0, 212, 255, 0.05) !important; }
.row-dim td { opacity: 0.5; }

.empty-cell {
    text-align: center !important;
    color: var(--text-muted);
    padding: 2.5rem 1rem !important;
}

.clickable-row { cursor: pointer; }
.clickable-row:hover td { color: var(--primary-accent); }

.action-btns {
    display: flex;
    gap: 0.35rem;
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-badge);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge-fixed {
    background: rgba(96, 165, 250, 0.1);
    color: var(--info);
    border: 1px solid rgba(96, 165, 250, 0.2);
}

.badge-variable {
    background: rgba(167, 139, 250, 0.1);
    color: var(--variable-accent);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.badge-mode-online {
    background: rgba(0, 212, 255, 0.1);
    color: var(--primary-accent);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.badge-mode-offline {
    background: rgba(255, 179, 71, 0.1);
    color: var(--secondary-accent);
    border: 1px solid rgba(255, 179, 71, 0.2);
}

.badge-status-active {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.badge-status-closed {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(100, 116, 139, 0.2);
}

.badge-status-cancelled {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
    text-decoration: line-through;
}

.badge-partial {
    background: rgba(251, 191, 36, 0.1);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-full {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.badge-interest-only {
    background: rgba(167, 139, 250, 0.1);
    color: var(--variable-accent);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-input);
    font-size: 0.825rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, #00d4ff, #0088ff);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.25);
}

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

.btn-success {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.25);
}

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

.btn-sm { padding: 0.4rem 0.875rem; font-size: 0.75rem; }
.btn-block { width: 100%; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-back {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
    width: 92%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-lg { max-width: 680px; }
.modal-sm { max-width: 400px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem 1.75rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.75rem;
    border-top: 1px solid var(--glass-border);
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group {
    margin-bottom: 1.15rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input, .form-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-input);
    padding: 0.7rem 0.9rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus {
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.form-input-sm {
    padding: 0.4rem 0.65rem !important;
    font-size: 0.8rem !important;
}

/* Dark mode for date/month pickers */
input[type="date"],
input[type="month"] {
    color-scheme: dark;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(0, 212, 255, 0.3) !important;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.8;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 1.25rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.input-with-prefix, .input-with-suffix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1;
}

.input-with-prefix .form-input {
    padding-left: 2rem;
}

.input-suffix {
    position: absolute;
    right: 0.875rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    pointer-events: none;
}

.input-with-suffix .form-input {
    padding-right: 8rem;
}

/* Toggle Group (Online/Offline) */
.toggle-group {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-input);
    color: var(--text-secondary);
    font-size: 0.825rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn:hover { border-color: var(--glass-border-hover); }

.toggle-btn.active[data-value="Online"] {
    border-color: var(--primary-accent);
    background: rgba(0, 212, 255, 0.08);
    color: var(--primary-accent);
}

.toggle-btn.active[data-value="Offline"] {
    border-color: var(--secondary-accent);
    background: rgba(255, 179, 71, 0.08);
    color: var(--secondary-accent);
}

.toggle-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.toggle-dot.online { background: var(--primary-accent); }
.toggle-dot.offline { background: var(--secondary-accent); }

/* ==========================================================================
   Calculated Interest Box (Repayment Modal)
   ========================================================================== */
.calculated-interest-box {
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: var(--radius-input);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
}

.calc-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.calc-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-accent);
}

.calc-detail {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.borrower-action-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.borrower-tile {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
}

.borrower-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.borrower-tile svg {
    color: var(--primary-accent);
    margin-bottom: 0.5rem;
}

.borrower-tile h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.borrower-tile p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

/* ==========================================================================
   Modals
   ========================================================================== */
/* ==========================================================================
   Reports
   ========================================================================== */
.report-controls {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.report-output {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.report-header {
    padding: 1.5rem;
    text-align: center;
}

.report-header h2 {
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
}

.report-header p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.report-card {
    overflow: visible;
}

.report-summary-row {
    display: flex;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
}

.report-metric {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.report-metric .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.report-metric .value {
    font-size: 1.15rem;
    font-weight: 700;
}

.report-metric.online .value { color: var(--primary-accent); }
.report-metric.offline .value { color: var(--secondary-accent); }
.report-metric.variable .value { color: var(--variable-accent); }
.report-metric.total .value { color: var(--text-primary); }

.report-repaid {
    padding: 0.75rem 1.5rem;
    background: rgba(52, 211, 153, 0.05);
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.825rem;
    color: var(--success);
    font-weight: 500;
}

/* ==========================================================================
   Monthly Summary Table
   ========================================================================== */
.summary-table th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ==========================================================================
   Empty States
   ========================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-icon {
    margin-bottom: 1.5rem;
    opacity: 0.4;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.empty-state p {
    max-width: 320px;
    font-size: 0.85rem;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-input);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-size: 0.825rem;
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid var(--primary-accent);
}

.toast.show {
    transform: translateX(0);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.toast-close:hover { color: var(--text-primary); }

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1280px) {
    .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
    .detail-summary-cards { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .dashboard-cards { grid-template-columns: 1fr 1fr; }
    .detail-summary-cards { grid-template-columns: 1fr 1fr 1fr; }
    .topbar { padding: 0 1.5rem; }
    .main-content { padding: 1.5rem; }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0.75rem;
        flex-direction: column;
        height: auto;
        gap: 0.5rem;
    }
    .topbar-left {
        width: 100%;
        justify-content: space-between;
        gap: 1rem;
    }
    .topbar-right {
        width: 100%;
        justify-content: flex-start;
        display: none; /* Hide export buttons on mobile to save space */
    }
    .topbar-nav {
        gap: 0.25rem;
    }
    .nav-link { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
    .logo-text { display: none; }
    .main-content {
        margin-top: 100px; /* Approximate height of stacked mobile topbar */
        padding: 1rem;
    }
    .dashboard-cards { grid-template-columns: 1fr; }
    .detail-summary-cards { grid-template-columns: 1fr 1fr; }
    .view-header { flex-direction: column; gap: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .borrower-grid { grid-template-columns: 1fr; }
    .report-summary-row { flex-direction: column; }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media screen {
    .print-only {
        display: none !important;
    }
}

@media print {
    body.print-mode-summary .modal-overlay#modal-monthly-summary,
    body.print-mode-statement .modal-overlay#modal-statement {
        display: flex !important;
        position: absolute;
        top: 0; left: 0;
        background: white;
        height: auto;
        overflow: visible;
        padding: 0;
        z-index: 99999;
    }
    body.print-mode-summary .modal#modal-monthly-summary .modal,
    body.print-mode-statement .modal#modal-statement .modal {
        box-shadow: none;
        max-width: 100%;
        margin: 0;
    }
    body.print-mode-summary .sidebar,
    body.print-mode-summary .topbar,
    body.print-mode-summary .main-content,
    body.print-mode-statement .sidebar,
    body.print-mode-statement .topbar,
    body.print-mode-statement .main-content {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: #1a1a1a !important;
    }

    .topbar,
    .modal-overlay,
    .toast-container,
    .btn,
    .header-actions,
    .tabs,
    .action-btns,
    .borrower-card-actions,
    .btn-back,
    .no-print {
        display: none !important;
    }

    .print-only {
        display: table-row !important;
    }

    .main-content {
        margin-top: 0 !important;
        padding: 0 !important;
    }

    .table-wrapper {
        overflow-x: visible !important;
        width: 100% !important;
    }
    
    .data-table {
        width: 100% !important;
        table-layout: auto !important;
    }

    .card, .metric-card, .report-card {
        background: white !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        break-inside: avoid;
    }

    .data-table th {
        background: #f5f5f5 !important;
        color: #333 !important;
    }

    .data-table td {
        border-bottom-color: #eee !important;
        color: #1a1a1a !important;
    }

    .metric-value, h1, h2, h3, strong {
        color: #1a1a1a !important;
    }

    .accent-online, .col-online { color: #0066cc !important; }
    .accent-offline, .col-offline { color: #cc6600 !important; }
    .accent-variable, .col-variable { color: #6633cc !important; }

    .badge {
        border: 1px solid #999 !important;
        color: #333 !important;
    }

    .view { display: none !important; }
    .view.active, #tab-content-monthly-summary { display: block !important; }
}

/* ==========================================================================
   Statement Modal & Content
   ========================================================================== */
.modal-xl { max-width: 900px; }
.modal-table { max-width: 1400px; width: 95%; }

.statement-content {
    padding: 0.5rem;
}

.statement-header-block {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--glass-border);
}

.statement-header-block h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.statement-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.statement-section {
    margin-bottom: 2rem;
}

.statement-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.statement-info-table {
    width: auto;
    border-collapse: collapse;
}

.statement-info-table td {
    padding: 0.35rem 1.25rem 0.35rem 0;
    font-size: 0.85rem;
    border: none !important;
}

.info-label {
    color: var(--text-muted);
    min-width: 160px;
    font-weight: 500;
}

.statement-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.statement-metric {
    padding: 0.875rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
}

.statement-metric .label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.statement-metric .value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 0.3rem;
    color: var(--text-primary);
}

.statement-table td {
    white-space: nowrap;
}

.statement-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}

.statement-footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.8;
}

@media (max-width: 768px) {
    .statement-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .modal-xl { max-width: 95%; }
}
. s t a t e m e n t - t a b l e - t h e m e d   t h   {   b a c k g r o u n d :   # 1 e 2 9 3 b   ! i m p o r t a n t ;   c o l o r :   w h i t e   ! i m p o r t a n t ;   b o r d e r :   1 p x   s o l i d   # 3 3 4 1 5 5 ;   }   . s t a t e m e n t - t a b l e - t h e m e d   t d   {   b o r d e r :   1 p x   s o l i d   # 3 3 4 1 5 5 ;   }   . s t a t e m e n t - t a b l e - t h e m e d   t b o d y   t r : n t h - c h i l d ( e v e n )   {   b a c k g r o u n d :   r g b a ( 2 5 5 , 2 5 5 , 2 5 5 , 0 . 0 2 ) ;   }  
 