@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #8b5cf6;       /* Primary purple from screenshots */
    --primary-hover: #7c3aed;
    --primary-light: #ede9fe;
    --bg: #f8fafc;            /* Light gray background */
    --surface: #ffffff;       /* Pure white cards */
    --sidebar-bg: #ffffff;    /* Light sidebar */
    --sidebar-text: #475569;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #8b5cf6;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --radius: 8px;            /* Softer border radius */
    --radius-sm: 4px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-hover: #475569;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { background: var(--sidebar-bg); display: flex; flex-direction: column; height: 100vh; overflow: hidden; color: var(--sidebar-text); border-right: 1px solid var(--border); }
.brand { padding: 1.5rem 1.5rem; font-weight: 700; font-size: 16px; color: var(--text-main); letter-spacing: 0.5px; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.brand::before { content: '🏦'; font-size: 20px; }
.nav { display: flex; flex-direction: column; gap: 0.2rem; padding: 0 1rem 3rem 1rem; flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(147, 51, 234, 0.2); border-radius: 4px; }
.nav::-webkit-scrollbar-thumb:hover { background: rgba(147, 51, 234, 0.5); }
.nav-item { padding: 0.6rem 1rem; color: var(--sidebar-text); text-decoration: none; cursor: pointer; border-radius: var(--radius); transition: all 0.2s ease; font-weight: 500; font-size: 13px; }
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { color: var(--sidebar-active); font-weight: 600; background: var(--primary-light); }
.nav-group-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; padding: 1.25rem 1rem 0.4rem; }

/* Main Area */
.main { display: flex; flex-direction: column; height: 100vh; min-width: 0; }
.topbar { height: 56px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 1.5rem; background: var(--surface); z-index: 10; }
.topbar .left { display: flex; align-items: center; color: var(--text-muted); cursor: pointer; }

.viewport { flex: 1; overflow-y: auto; padding: 2rem; }
.page { display: none; }
.page.active { display: block; animation: fade-in 0.2s ease-out forwards; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Typography */
h1 { font-size: 24px; font-weight: 600; color: var(--text-main); margin-bottom: 1.5rem; }
h2 { font-size: 16px; font-weight: 600; color: var(--text-main); margin: 2rem 0 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

/* Open Design Standard Button System */
.btn { 
    font-family: inherit; 
    font-size: 13px; 
    font-weight: 500; 
    padding: 0.45rem 1rem; 
    height: 36px;
    cursor: pointer; 
    border-radius: 6px; 
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1); 
    border: 1px solid transparent; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.4rem; 
    white-space: nowrap;
    outline: none;
    box-sizing: border-box;
}
.btn-sm {
    padding: 0.25rem 0.65rem;
    height: 30px;
    font-size: 12px;
    border-radius: 6px;
}
.btn-primary { 
    background: #8b5cf6; 
    color: white; 
    border-color: #8b5cf6;
    box-shadow: 0 1px 2px 0 rgba(139, 92, 246, 0.2);
}
.btn-primary:hover { 
    background: #7c3aed; 
    border-color: #7c3aed;
    box-shadow: 0 2px 4px 0 rgba(124, 58, 237, 0.3); 
}
.btn-outline { 
    background: #ffffff; 
    color: #334155; 
    border-color: #e2e8f0; 
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}
.btn-outline:hover { 
    background: #f8fafc; 
    color: #0f172a;
    border-color: #cbd5e1; 
}
.btn-ghost { 
    background: transparent; 
    color: #64748b; 
    border-color: transparent;
}
.btn-ghost:hover { 
    color: #1e293b; 
    background: #f1f5f9; 
}

/* Subtle Action Buttons (Open Design Standard) */
.btn-subtle-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.btn-subtle-success:hover {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.btn-subtle-purple {
    background: #faf5ff;
    color: #7e22ce;
    border: 1px solid #e9d5ff;
}
.btn-subtle-purple:hover {
    background: #f3e8ff;
    color: #6b21a8;
    border-color: #d8b4fe;
}

.btn-subtle-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.btn-subtle-danger:hover {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 2rem; }
.stat-box { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); border-top: 3px solid var(--primary); }
.stat-lbl { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; margin-bottom: 0.5rem; }
.stat-val { font-size: 28px; font-weight: 700; color: var(--text-main); }

/* Forms & Filters */
.toolbar { display: flex; gap: 1rem; margin-bottom: 1.5rem; align-items: flex-end; background: var(--surface); padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.toolbar .btn { align-self: flex-end; height: 36px; }
.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group label { font-size: 12px; font-weight: 600; color: var(--text-main); }
input, select { background: var(--surface); color: var(--text-main); border: 1px solid var(--border); padding: 0.5rem 0.75rem; font-family: inherit; font-size: 13px; border-radius: var(--radius-sm); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* Radio Options */
.radio-options { display: flex; gap: 1.5rem; padding: 0.5rem 0; }
.radio-options label { font-size: 13px !important; color: var(--text-main) !important; font-weight: 400 !important; display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
input[type="radio"] { cursor: pointer; }

/* Tables */
.table-wrapper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 1rem 1.5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.link-cell { color: var(--primary); cursor: pointer; font-weight: 500; }
.link-cell:hover { text-decoration: underline; }
.text-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.tag { display: inline-flex; padding: 0.25rem 0.6rem; font-size: 11px; font-weight: 600; border-radius: 4px; background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; padding: 1rem; gap: 1rem; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.page-btn { padding: 0.2rem 0.6rem; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.action-link { color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: none; margin-right: 0.5rem; }
.action-link:hover { text-decoration: underline; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 2rem; gap: 2rem; padding: 0 1rem; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.tab { padding: 1rem 0; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; font-size: 14px; font-weight: 500; transition: all 0.2s; margin-bottom: -1px; }
.tab:hover { color: var(--text-main); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; background: var(--surface); padding: 2rem; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); margin-top: -2rem; box-shadow: var(--shadow); }
.tab-content.active { display: block; animation: fade-in 0.2s ease-out forwards; }

/* Forms Grid */
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; }
.req { color: #dc2626; margin-right: 2px; }

/* Photos Layout */
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1.5rem; }
.upload-group { display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 1.25rem; border-radius: var(--radius); border: 1px solid var(--border); gap: 1rem; transition: box-shadow 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.upload-group:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); }
.upload-group label { flex: 1; font-weight: 600; font-size: 13px; color: var(--text-main); line-height: 1.4; }
.upload-area { width: 140px; height: 100px; border: 1px dashed var(--border-hover); background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm); transition: all 0.2s; position: relative; overflow: hidden; flex-shrink: 0; }
.upload-area:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.upload-area i.fa-arrow-up-from-bracket { font-size: 24px; color: #94a3b8; }
.upload-area:hover i.fa-arrow-up-from-bracket { color: var(--primary); }

.upload-area img.preview-img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; }
.upload-area .preview-pdf { font-size: 36px; color: #dc2626; }
.upload-overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.7); color: white; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; font-weight: 500; font-size: 13px; cursor: pointer; }
.upload-area:hover .upload-overlay { opacity: 1; }

/* Open Design Modern UI Components */
.modern-list { display: flex; flex-direction: column; overflow: visible; position: relative; }
.modern-card { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 1.5rem; display: flex; align-items: center; justify-content: space-between; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); gap: 1.5rem; }
.modern-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-hover); }

/* Borderless Modern Row for High-Density Lists */
.modern-row { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); transition: background 0.2s; }
.modern-row:hover { background: rgba(139, 92, 246, 0.03); }
.modern-row:last-child { border-bottom: none; }
.id-link { color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: none; transition: opacity 0.2s; }
.id-link:hover { opacity: 0.8; text-decoration: underline; }

.mc-col { display: flex; flex-direction: column; gap: 0.2rem; }
.mc-lbl { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.mc-val { font-size: 14px; font-weight: 500; color: var(--text-main); }
.mc-val.amount { font-family: monospace; font-size: 15px; font-weight: 600; color: #15803d; }

.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.75rem; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-yellow { background: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.badge-purple { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }

/* Open Design Detail View Blocks */
.info-block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.info-block { background: var(--bg); border: 1px solid var(--border); padding: 1.25rem; border-radius: 12px; display: flex; align-items: flex-start; gap: 1rem; transition: background 0.2s; }
.info-block:hover { background: var(--surface); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.info-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.info-content { display: flex; flex-direction: column; gap: 0.2rem; }
.info-title { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.info-data { font-size: 15px; font-weight: 600; color: var(--text-main); word-break: break-word; }

/* Open Design Form & Dashboard Components */
.form-card { background: var(--surface); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 2rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.form-card-title { font-size: 14px; font-weight: 600; color: var(--text-main); margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }
.form-card-title i { color: var(--primary); }

.dash-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.dash-welcome h1 { font-size: 28px; margin-bottom: 0.2rem; }
.dash-welcome p { color: var(--text-muted); font-size: 14px; }

.trend-up { color: #15803d; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; background: #dcfce7; padding: 2px 6px; border-radius: 4px; }
.trend-down { color: #b91c1c; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; background: #fee2e2; padding: 2px 6px; border-radius: 4px; }

/* Dropdown Actions Menu */
.dropdown-wrapper { position: relative; display: inline-block; cursor: pointer; }
.dropdown-wrapper .action-dots { color: var(--primary); padding: 0.2rem 0.6rem; border-radius: 4px; font-weight: bold; font-size: 18px; line-height: 1; letter-spacing: 2px; }
.dropdown-wrapper:hover .action-dots { background: rgba(139, 92, 246, 0.1); }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: 100%; min-width: 160px;
    background: white; border: 1px solid var(--border); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-radius: 6px; z-index: 100; padding: 0.5rem 0;
}
.dropdown-wrapper:hover .dropdown-menu { display: block; animation: fade-in 0.2s ease-out forwards; }
.dropdown-item { padding: 0.5rem 1rem; font-size: 13px; color: var(--text-main); display: block; text-decoration: none; transition: background 0.2s; white-space: nowrap; }
.dropdown-item:hover { background: rgba(0,0,0,0.03); text-decoration: none; }
.dropdown-item.disabled { color: #cbd5e1; pointer-events: none; }
.dropdown-item.danger { color: #ef4444; }
.dropdown-item.danger:hover { background: #fef2f2; }

/* Helpers */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.mb-1 { margin-bottom: 1rem; }

/* Toggle Switch (Open Design el-switch alternative) */
.toggle-switch {
    position: relative; display: inline-block; width: 36px; height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1; transition: .3s; border-radius: 20px;
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px;
    background-color: white; transition: .3s; border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(16px); }
input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

/* Two-Pane Layout for Form Configuration */
.pane-layout { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 500px; background: var(--surface); }
.pane-sidebar { width: 260px; border-right: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; }
.pane-sidebar-header { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; gap: 0.5rem; }
.pane-sidebar-list { flex: 1; overflow-y: auto; }
.pane-sidebar-item { padding: 0.75rem 1rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); transition: background 0.2s; font-size: 13px; font-weight: 500; color: var(--text-main); }
.pane-sidebar-item:hover { background: rgba(0,0,0,0.02); }
.pane-sidebar-item.active { background: var(--surface); border-right: 2px solid var(--primary); margin-right: -1px; position: relative; z-index: 1; font-weight: 600; color: var(--primary); }
.pane-sidebar-item .trash-icon { color: #ef4444; opacity: 0; transition: opacity 0.2s; font-size: 12px; }
.pane-sidebar-item:hover .trash-icon { opacity: 1; }
.pane-main { flex: 1; display: flex; flex-direction: column; background: var(--surface); }
.pane-main-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; color: var(--text-main); background: var(--surface); }
.pane-main-content { flex: 1; overflow-y: auto; padding: 0; }
.pane-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.pane-table th { padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--bg); color: var(--text-muted); font-weight: 500; position: sticky; top: 0; z-index: 1; }
.pane-table td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pane-table tr.disabled td { color: var(--text-muted); opacity: 0.7; }


/* Modal Styles */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.8); display: none; align-items: center; justify-content: center; z-index: 1000; opacity: 0; transition: opacity 0.2s; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-content { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); max-width: 900px; width: 90%; max-height: 90vh; display: flex; flex-direction: column; position: relative; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: var(--surface); border: 1px solid var(--border); width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); z-index: 2; transition: all 0.2s; }
.modal-close:hover { background: var(--bg); color: var(--text-main); border-color: var(--border-hover); }
.modal-body { flex: 1; overflow: hidden; display: flex; justify-content: center; align-items: center; background: var(--bg); border-radius: var(--radius-sm); min-height: 400px; border: 1px solid var(--border); }
.modal-body img { max-width: 100%; max-height: calc(90vh - 4rem); object-fit: contain; }
.modal-body iframe { width: 100%; height: calc(90vh - 4rem); border: none; }

/* Responsive Design - Tablet & Mobile Adaptations */
@media (max-width: 1024px) {
    /* Tablet Layout */
    .app { grid-template-columns: 200px 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    
    /* Protect Data Streams */
    .modern-list, .table-wrapper { overflow-x: auto; padding-bottom: 0.5rem; }
    .modern-row, .modern-list-header { min-width: 900px; }
    /* Disbursement grid: header and body must scroll together via .table-card-wrapper, never independently */
    #page-disbursement .modern-list { overflow: visible; padding-bottom: 0; }
}

@media (max-width: 768px) {
    /* Mobile Layout */
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; } /* Default hidden on mobile for clean UI */
    
    .viewport { padding: 1rem; }
    
    /* Collapsing Grids & Toolbars */
    .stats-grid { grid-template-columns: 1fr; }
    .grid-form { grid-template-columns: 1fr !important; }
    .info-block-grid { grid-template-columns: 1fr; }
    
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .input-group, .toolbar input, .toolbar select { width: 100% !important; }
    .toolbar .btn { width: 100%; margin-top: 0 !important; }
    
    /* Cards & Modals */
    .modern-card { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .modern-card .mc-col { width: 100%; align-items: flex-start !important; }
    .modern-card .mc-col .badge { align-self: flex-start; }
    .modern-card .mc-col[style*="flex-direction:row"] { justify-content: flex-start !important; }
    
    .modal-content { width: 95% !important; max-width: 100% !important; height: auto; max-height: 95vh; border-radius: 12px; padding: 1.25rem; margin: 10px; }
    
    /* Tabs Scroll */
    .tabs { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap; padding-bottom: 0.5rem; }
    .tab-content { padding: 1rem; margin-top: -1.5rem; }
}

/* --- LMS operational workspace badge variants --- */
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.2); }
.badge-amber { background: rgba(245, 158, 11, 0.1); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-green { background: rgba(16, 185, 129, 0.1); color: #059669; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-blue { background: rgba(14, 165, 233, 0.1); color: #0284c7; border: 1px solid rgba(14, 165, 233, 0.2); }

/* --- Branch & Sales Team (Open Design Extensions) --- */

/* Open Design Smooth Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  vertical-align: middle;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
  border-radius: 24px;
}
.slider:hover {
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
input:checked + .slider {
  background-color: #9333ea;
}
input:checked + .slider:hover {
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.25);
}
input:checked + .slider:before {
  transform: translateX(22px);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
}
.status-pill.active {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.status-pill.disabled {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Three-Column Team Layout */
.team-layout {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 540px;
}
.team-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(147, 51, 234, 0.02);
}
.team-card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.team-card-body {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

/* Tree & List items */
.tree-node-item {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tree-node-item:hover {
  background: var(--bg-main);
}
.tree-node-item.active {
  background: rgba(147, 51, 234, 0.08);
  border-color: rgba(147, 51, 234, 0.3);
  color: #9333ea;
  font-weight: 600;
}

.person-card {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  background: var(--surface);
  transition: all 0.2s ease;
  cursor: pointer;
}
.person-card:hover {
  border-color: rgba(147, 51, 234, 0.4);
  box-shadow: var(--shadow-sm);
}
.person-card.active {
  border-color: #9333ea;
  background: rgba(147, 51, 234, 0.04);
}

/* Drawer Control */
.drawer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.drawer-content {
  position: absolute;
  top: 0; right: -480px; bottom: 0;
  width: 440px;
  max-width: 90vw;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-overlay.active .drawer-content {
  right: 0;
}
.drawer-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.drawer-body {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
}
.drawer-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Transfer Box */
.transfer-box {
  display: grid;
  grid-template-columns: 1fr 50px 1fr;
  gap: 0.75rem;
  align-items: center;
}
.transfer-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 280px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.transfer-panel-header {
  padding: 0.6rem 0.85rem;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.transfer-panel-body {
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
}
.transfer-item {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}
.transfer-item:hover {
  background: var(--bg-main);
}
.transfer-item.selected {
  background: rgba(147, 51, 234, 0.1);
  color: #9333ea;
}
.transfer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

/* V3.0 LMS Specific Styles */
.badge-blue { background: #e0f2fe; color: #0284c7; }
.badge-amber { background: #fef3c7; color: #d97706; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #475569; }

.grid-15-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.grid-15-table th, .grid-15-table td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: right;
}
.grid-15-table th {
  background: var(--bg);
  font-weight: 600;
  text-align: center;
}
.grid-15-table th:first-child, .grid-15-table td:first-child {
  text-align: left;
}
.grid-list-header {
  display: grid;
  align-items: center;
  padding: 0.85rem 1.5rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.grid-list-header > div, .grid-list-row > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid-list-header > div:last-child, .grid-list-row > div:last-child {
  overflow: visible;
}
.grid-list-row {
  display: grid;
  align-items: center;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  background: var(--surface);
  position: relative;
}
.grid-list-row:has(.dropdown-menu.show) {
  z-index: 50;
}
.grid-list-row:hover {
  background: var(--bg);
}

.repay-grid-cols {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 0.85fr) minmax(0, 1fr) 170px;
}
.po-grid-cols {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.3fr) minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1.2fr) 160px;
}
.rpo-grid-cols {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.25fr) minmax(0, 1.05fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1.2fr) 160px;
}
.rph-grid-cols {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.05fr) minmax(0, 1.05fr) minmax(0, 1.2fr) minmax(0, 1.5fr) minmax(0, 0.85fr) 120px;
}

/* Repayment proof upload dropzone */
.upload-dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 1.1rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.05);
}
.upload-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  margin-top: 0.45rem;
  font-size: 12px;
}

/* Action Dropdown Component */
.action-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.dropdown-menu {
  position: absolute;
  right: 0;
  top: 36px;
  z-index: 120;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 6px;
  display: none;
}
.dropdown-menu.show {
  display: block;
  animation: dropdown-fade-in 0.15s cubic-bezier(0, 0, 0.2, 1) forwards;
}
@keyframes dropdown-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  font-size: 12.5px;
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
}
.dropdown-item:hover {
  background: var(--bg);
}
.dropdown-item.danger {
  color: #dc2626;
}
.dropdown-item.danger:hover {
  background: #fef2f2;
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Open Design Resizable Table & Data Grid System */
.table-card-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.table-card-wrapper::-webkit-scrollbar {
    height: 6px;
}
.table-card-wrapper::-webkit-scrollbar-track {
    background: var(--bg);
}
.table-card-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
.table-card-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}
.col-resizer::after {
    content: '';
    width: 2px;
    height: 60%;
    background: var(--border);
    border-radius: 1px;
    transition: background 0.15s ease, opacity 0.15s ease;
    opacity: 0.5;
}
.col-resizer:hover::after, .col-resizer.active::after {
    background: var(--primary);
    opacity: 1;
    width: 3px;
}

/* Disbursement Center Enhancements */
#page-disbursement #disb-list-header { position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 var(--border); }
#page-disbursement .disb-stat, #page-repayment .disb-stat { display: flex; align-items: center; gap: 1rem; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
#page-disbursement .disb-stat:hover, #page-repayment .disb-stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-hover); }
#page-disbursement .disb-stat-icon, #page-repayment .disb-stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
#page-disbursement .disb-stat-body, #page-repayment .disb-stat-body { flex: 1; min-width: 0; }
#page-disbursement .disb-stat-body .stat-lbl, #page-repayment .disb-stat-body .stat-lbl { margin-bottom: 2px; }
#page-disbursement .disb-stat-body .stat-val, #page-repayment .disb-stat-body .stat-val { font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
#page-disbursement .disb-stat-sub, #page-repayment .disb-stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
#page-disbursement .disb-stat-arrow, #page-repayment .disb-stat-arrow { color: var(--text-muted); font-size: 12px; opacity: 0; transition: opacity 0.2s, transform 0.2s; }
#page-disbursement .disb-stat:hover .disb-stat-arrow, #page-repayment .disb-stat:hover .disb-stat-arrow { opacity: 1; transform: translateX(2px); }

#page-disbursement .tab, #page-repayment .tab { display: flex; align-items: center; gap: 0.5rem; }
#page-disbursement .tab-count, #page-repayment .tab-count { background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); font-size: 11px; font-weight: 600; border-radius: 99px; padding: 0.05rem 0.55rem; font-variant-numeric: tabular-nums; }
#page-disbursement .tab.active .tab-count, #page-repayment .tab.active .tab-count { background: var(--primary-light); border-color: transparent; color: var(--primary); }

#page-disbursement .disb-num { text-align: right; font-variant-numeric: tabular-nums; }

#page-disbursement .disb-empty { text-align: center; padding: 3.5rem 1rem; color: var(--text-muted); }
#page-disbursement .disb-empty > i { font-size: 28px; opacity: 0.35; margin-bottom: 0.75rem; display: block; }

#page-disbursement .modern-list-item { transition: background 0.15s; }
#page-disbursement .modern-list-item:hover { background: rgba(139, 92, 246, 0.03); }
#page-disbursement .modern-list-item:hover .disb-actions-cell { background: color-mix(in srgb, var(--surface) 97%, var(--primary)); }

/* Action popover: class-driven visibility + row elevation so the menu never renders under later rows */
#page-disbursement .disb-action-popover { display: none; }
#page-disbursement .disb-action-popover.show { display: block; animation: dropdown-fade-in 0.15s cubic-bezier(0, 0, 0.2, 1) forwards; }
#page-disbursement .modern-list-item:has(.disb-action-popover.show) { z-index: 60; }

/* Uniform action buttons across the three queue tabs so the pinned column reads as one aligned block */
#page-disbursement .disb-action-btn { min-width: 92px; justify-content: center; }

/* Pagination */
#page-disbursement .page-btn:disabled { opacity: 0.4; cursor: default; }
#page-disbursement .page-btn:not(.active):not(:disabled):hover { border-color: var(--primary); color: var(--primary); }

/* Pagination (ledger detail tabs) */
#page-ledger-detail .page-btn:disabled { opacity: 0.4; cursor: default; }
#page-ledger-detail .page-btn:not(.active):not(:disabled):hover { border-color: var(--primary); color: var(--primary); }

/* --- Manual Entry Full-Screen Modal --- */
.modal-fullscreen { align-items: center; justify-content: center; }
.modal-fullscreen.active { display: flex; }
.modal-content-fullscreen {
    width: 94%;
    max-width: 1180px;
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
    background: var(--bg);
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.35);
}

/* Manual Entry — header / footer chrome */
.man-entry-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.man-entry-header-title {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-right: auto;
    min-width: 0;
}
.man-entry-header-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.man-entry-header h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-main); }
.man-entry-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }

.man-entry-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.man-entry-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.75rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* Numbered section cards */
.man-entry-section { margin: 0; }
.man-entry-section .form-card-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    font-size: 15px;
}
.me-badge {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Segmented control — Entry Mode */
.man-entry-segmented {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
    margin-bottom: 1.25rem;
}
.me-seg-btn {
    padding: 0.5rem 1.25rem;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s;
    font-family: inherit;
}
.me-seg-btn:hover { color: var(--text-main); }
.me-seg-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}
.me-seg-btn.active i { color: var(--primary); }

/* Entry Mode conditional rows */
.man-entry-mode-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Info callouts */
.me-notice {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    font-size: 12.5px;
    line-height: 1.5;
}
.me-notice i { margin-top: 2px; flex-shrink: 0; }
.me-notice.success { background: rgba(16, 185, 129, 0.07); border: 1px solid rgba(16, 185, 129, 0.22); color: #059669; }
.me-notice.warn { background: rgba(245, 158, 11, 0.07); border: 1px solid rgba(245, 158, 11, 0.22); color: #d97706; }

/* Live repayment preview */
.man-entry-preview {
    margin-top: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.me-pv-item { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.me-pv-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.me-pv-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.me-pv-value.highlight { color: var(--primary); }

@media (max-width: 900px) {
    .man-entry-preview { grid-template-columns: repeat(2, 1fr); }
    .man-entry-mode-row { flex-direction: column; align-items: stretch; }
}

@media (max-width: 768px) {
    .modal-content.modal-content-fullscreen {
        width: 96% !important;
        max-width: 96% !important;
        height: 92vh !important;
        max-height: 92vh !important;
        padding: 0 !important;
        margin: 10px !important;
        border-radius: 12px !important;
    }
    .man-entry-header { padding: 1rem 1.25rem; }
    .man-entry-body { padding: 1.25rem; }
    .man-entry-footer { padding: 0.85rem 1.25rem; }
    .man-entry-sub { display: none; }
}

/* Customer search dropdown item */
.cust-combobox {
    position: relative;
    display: flex;
    align-items: center;
}
.cust-combobox input {
    flex: 1;
    padding-right: 2rem;
}
.cust-combobox > .fa-chevron-down {
    position: absolute;
    right: 0.7rem;
    font-size: 11px;
    color: var(--text-muted);
    pointer-events: none;
}
.cust-combobox-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
}
.cust-combobox:focus-within .cust-combobox-dropdown:not(:empty),
.cust-combobox .cust-combobox-dropdown.has-results {
    display: block;
}
.cust-search-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.cust-search-item:hover { background: var(--bg); }
.cust-search-item .cust-name { font-weight:600; font-size:13px; color:var(--text-main); }
.cust-search-item .cust-mobile { font-size:11px; color:var(--text-muted); }
.cust-search-no-results { padding: 1rem; text-align:center; color:var(--text-muted); font-size:12px; }

/* ───────────────────────────────────────────────
   Ledger Detail Page
   ─────────────────────────────────────────────── */
.ledger-detail-banner {
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Portfolio Ledger list — card-wrapped table rows */
#page-ledger .modern-list-item { transition: background 0.15s; }
#page-ledger .modern-list-item:hover { background: rgba(139, 92, 246, 0.03); }
#page-ledger .modern-list-item:last-child { border-bottom: none; }

/* Attribution card — purple left border */
.attribution-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid #8b5cf6;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}
.attribution-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.attribution-header i { color: #8b5cf6; }
.attribution-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.attribution-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.attribution-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.attribution-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

/* Param card (generic for sections 2-4) */
.param-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

/* 3-column param grid */
.param-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem 2rem;
}
.param-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.param-item:nth-last-child(-n+3) { border-bottom: none; }
.param-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.param-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}
.param-value.amount {
    font-family: monospace;
    color: #15803d;
}

/* OS Stat Cards */
.os-stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: 3px solid var(--os-accent);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.os-stat-lbl {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}
.os-stat-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

/* Total Outstanding Bar */
.total-outstanding-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
}

/* Repaid items */
.repaid-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: center;
}
.repaid-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.repaid-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

/* Timeline */
.timeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 1rem 0;
}
.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    min-width: 90px;
    text-align: center;
}
.tn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #8b5cf6;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px #8b5cf6;
}
.tn-dot-dim {
    background: #cbd5e1;
    box-shadow: 0 0 0 2px #cbd5e1;
}
.timeline-node.tn-dim .tn-label { color: var(--text-muted); }
.timeline-node.tn-dim .tn-date { color: var(--text-muted); }
.tn-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.tn-date {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
}
.timeline-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin-top: 5px;
    min-width: 30px;
}

/* Delinquency row */
.delinquency-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    margin-top: 0.75rem;
}

/* Detail tab sub-grids (字段与放款/还款历史页签保持一致) */
.ld-rh-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.05fr) minmax(0, 1.05fr) minmax(0, 1.2fr) minmax(0, 1.5fr) minmax(0, 0.85fr);
}
.ld-dh-grid {
    grid-template-columns: 120px 120px 150px 180px 120px 120px 110px 120px 130px 120px 110px 140px minmax(220px, 1fr);
}
.ld-adj-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 2.4fr) minmax(0, 0.9fr) minmax(0, 1.2fr);
}
#ld-tab-disb-history { overflow-x: auto; }
#ld-disb-history-body { min-width: 1760px; }


/* ==================== Collection & Recovery module ==================== */
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 860px; }
textarea {
    background: var(--surface); color: var(--text-main);
    border: 1px solid var(--border); padding: 0.5rem 0.75rem;
    font-family: inherit; font-size: 13px; border-radius: var(--radius-sm);
    outline: none; width: 100%; resize: vertical; transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.coll-kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.coll-kv { background: var(--surface); padding: 0.75rem 1rem; min-width: 0; }
.coll-kv .k { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.coll-kv .v { font-size: 13px; font-weight: 600; color: var(--text-main); margin-top: 2px; overflow-wrap: anywhere; }
.coll-kv .v.mono { font-family: monospace; font-variant-numeric: tabular-nums; }
.coll-stepper { display: flex; align-items: center; gap: 0; overflow-x: auto; }
.coll-step { display: flex; align-items: center; gap: 8px; flex: none; }
.coll-node { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--text-muted); border: 2px solid var(--border); font-size: 12px; font-weight: 700; }
.coll-node.done { background: var(--primary); border-color: var(--primary); color: #fff; }
.coll-node.current { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-light); }
.coll-node.warn { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.coll-step .slabel { font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.coll-step .slabel.active { color: var(--text-main); font-weight: 700; }
.coll-link { flex: 1; height: 2px; background: var(--border); margin: 0 10px; min-width: 18px; }
.coll-link.done { background: var(--primary); }
.coll-timeline { padding: 4px 0; }
.coll-tl { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--border); margin-left: 6px; }
.coll-tl:last-child { border-left-color: transparent; padding-bottom: 4px; }
.coll-tl::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.coll-tl.success::before { border-color: #10b981; }
.coll-tl.warn::before { border-color: #f59e0b; }
.coll-tl .tt { font-size: 13px; font-weight: 600; color: var(--text-main); }
.coll-tl .tm { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-top: 1px; }
.coll-tl .tx { font-size: 12px; color: var(--fg-2, #334155); margin-top: 4px; }
.coll-bar-row { display: grid; grid-template-columns: 96px 1fr 120px; align-items: center; gap: 12px; padding: 7px 0; }
.coll-bar-label { font-size: 12px; font-weight: 600; color: var(--fg-2, #334155); }
.coll-bar-track { height: 12px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.coll-bar { height: 100%; border-radius: 4px; background: var(--primary); width: 0; transition: width 500ms cubic-bezier(0.4,0,0.2,1); }
.coll-bar.warn { background: #f59e0b; }
.coll-bar.danger { background: #dc2626; }
.coll-bar-value { font-family: monospace; font-size: 12px; text-align: right; color: var(--fg-2, #334155); }
.coll-alert { display: flex; align-items: center; gap: 12px; padding: 12px 1.5rem; border-bottom: 1px solid var(--border); }
.coll-alert:last-child { border-bottom: none; }
.coll-alert .ic { width: 30px; height: 30px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; }
.coll-alert .bd { flex: 1; min-width: 0; }
.coll-alert .t { font-size: 13px; font-weight: 600; color: var(--text-main); }
.coll-alert .d { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.coll-alert .go { font-size: 12px; font-weight: 600; color: var(--primary); white-space: nowrap; }
