:root { --primary: #1e3a8a; --accent: #3b82f6; --bg: #f8fafc; --warn: #f59e0b; --danger: #ef4444; --success: #10b981; --purple: #7e22ce; --loan: #d97706; }
body { font-family: 'Sarabun', sans-serif; margin: 0; display: flex; height: 100vh; background: var(--bg); overflow: hidden; font-size: 14px; color: #334155; }

/* Layout & UI Components */
#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #1e3a8a, #3b82f6); z-index: 5000; display: flex; justify-content: center; align-items: center; flex-direction: column; color: white; transition: 0.5s; }
.login-box { background: white; padding: 40px; border-radius: 15px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); text-align: center; width: 350px; color: #333; }
.login-box input { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ddd; border-radius: 6px; font-family: 'Sarabun'; }
.btn-login { background: var(--primary); color: white; width: 100%; padding: 12px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; margin-top: 10px; }

.sidebar { width: 260px; background: var(--primary); color: white; display: flex; flex-direction: column; flex-shrink: 0; z-index: 100; box-shadow: 2px 0 5px rgba(0,0,0,0.1); }
.brand { padding: 25px; text-align: center; background: rgba(0,0,0,0.2); }
.user-info { padding: 10px; background: rgba(0,0,0,0.1); font-size: 0.85em; text-align: center; color: #93c5fd; border-bottom: 1px solid rgba(255,255,255,0.1); }
.menu-scroll-wrap { flex: 1; overflow-y: auto; }
.menu-item { padding: 10px 25px; cursor: pointer; display: flex; align-items: center; border-left: 4px solid transparent; color: #dbeafe; transition: 0.2s; }
.menu-item:hover { background: rgba(255,255,255,0.1); }
.menu-item.active { background: rgba(255,255,255,0.15); border-left-color: var(--accent); color: white; font-weight: 600; }
.menu-group { font-size: 0.75rem; color: #93c5fd; padding: 15px 25px 5px; text-transform: uppercase; font-weight: bold; margin-top: 10px; border-top: 1px solid rgba(255,255,255,0.1); }

.main { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; opacity: 0; transition: 1s; } 
.card { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); margin-bottom: 20px; border: 1px solid #e2e8f0; display: flex; flex-direction: column; height: 100%; }
.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px; }
.page-section { display: none; height: 100%; flex-direction: column; }
.page-section.active { display: flex; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; gap: 2px; }
.tab-btn { padding: 10px 20px; cursor: pointer; border: none; background: #f8fafc; font-weight: 600; color: #64748b; border-radius: 8px 8px 0 0; }
.tab-btn.active { background: white; color: var(--primary); border-top: 3px solid var(--accent); border-bottom: 2px solid white; margin-bottom: -2px; }
.tab-content { display: none; height: 100%; flex-direction: column; }
.tab-content.active { display: flex; }
.modal { display: none; align-items: center; justify-content: center; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); }
.modal.show { display: flex !important; }

.table-container { flex: 1; overflow: auto; border: 1px solid #e2e8f0; border-radius: 8px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: 0.9em; min-width: 800px; }
th { background: #f8fafc; padding: 10px; position: sticky; top: 0; text-align: center; border-bottom: 2px solid #e2e8f0; color: #475569; z-index: 10; white-space: nowrap; font-weight: 600; }
td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; white-space: nowrap; }

input.tbl-inp, select.tbl-inp { width: 100%; background: transparent; border: 1px solid transparent; text-align: right; font-family: 'Sarabun'; padding: 4px; border-radius: 4px; font-size: 0.9em; box-sizing: border-box; }
input.tbl-inp:focus { border: 1px solid #cbd5e1; background: #fffbeb; outline: none; }
input.inp-gl { background-color: #fffbeb; border: 1px solid #fcd34d; color: #92400e; font-weight: 600; }

tfoot tr { background-color: #ecfeff; font-weight: bold; color: #0e7490; position: sticky; bottom: 0; z-index: 10; border-top: 2px solid #bae6fd; }
tfoot td { text-align: right; padding: 10px; border-top: 2px solid #bae6fd; }

.btn { padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; color: white; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 5px; font-family: 'Sarabun'; text-decoration: none;}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-add { background: var(--accent); }
.btn-save { background: var(--warn); width: 100%; justify-content: center; padding: 12px; font-weight: bold; font-size: 1rem; margin-top: 10px;}
.btn-logout { background: #ef4444; width: 100%; justify-content: center; padding: 10px; margin-top: 5px; font-size: 0.9rem;}
.btn-print { background: #374151; }
.btn-import { background: #8b5cf6; }
.btn-excel { background: var(--success); }
.btn-del { background: var(--danger); padding: 4px 8px; font-size: 0.7em; border-radius: 3px; color: white; border: none; cursor: pointer;}
.btn-list { background: #6366f1; padding: 2px 8px; font-size: 0.8rem; margin-left: 5px; border-radius: 4px;}
.btn-magic { background: linear-gradient(135deg, #8b5cf6, #d946ef); color:white; font-weight:bold; }
.btn-gray { background: #64748b; }

.cit-section { margin-bottom: 20px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; background: #fff; }
.cit-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 0.95em; }
.cit-row input { width: 100px; text-align: right; padding: 4px; border: 1px solid #cbd5e1; border-radius: 4px; font-family: 'Sarabun'; }
.cit-head { font-weight: bold; color: var(--primary); border-bottom: 1px solid #eee; padding-bottom: 5px; margin-bottom: 10px; }

.detail-display { margin-left: 20px; padding: 5px 10px; background: #f8fafc; border-left: 3px solid #cbd5e1; font-size: 0.85em; color: #475569; margin-bottom: 10px; display: none; }
.detail-display div { display: flex; justify-content: space-between; margin-bottom: 2px; border-bottom: 1px dotted #ddd; }

.switch { position: relative; display: inline-block; width: 40px; height: 20px; margin-left: 10px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #10b981; }
input:checked + .slider:before { transform: translateX(20px); }

#det-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; display: none; justify-content: center; align-items: center; }
.det-box { background: white; padding: 20px; border-radius: 8px; width: 450px; max-width: 90%; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }

.bank-grid { display: grid; grid-template-columns: 1.5fr 3.5fr; gap: 20px; height: 100%; min-height: 400px; }
.bank-col { display: flex; flex-direction: column; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; background: white; }
.cust-item { padding: 10px; border-bottom: 1px solid #eee; cursor: pointer; transition: 0.2s; display: flex; justify-content: space-between; align-items: center; }
.cust-item.active { background: #e0f2fe; border-left: 4px solid var(--primary); font-weight: bold; }

.highlight-box { background: #f3e8ff; border: 1px solid #d8b4fe; padding: 10px; border-radius: 6px; margin-bottom: 15px; font-size: 0.9em; color: #581c87; }
.col-actual { background-color: #f0fdf4; } .col-forecast { background-color: #fffbeb; } 
.text-right { text-align: right !important; } .center { text-align: center !important; }
.font-bold { font-weight: bold; } .mb-2 { margin-bottom: 8px; } .mt-3 { margin-top: 12px; }
.diff-ok { color: #10b981; font-weight: bold; } .diff-err { color: #ef4444; font-weight: bold; }

/* Loan Report Dashboard */
.loan-card {
    transition: transform 0.2s, box-shadow 0.2s;
}
.loan-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15) !important;
}

@media print {
    .sidebar, .no-print, .btn, input[type="file"], #login-overlay, #print-options-modal { display: none !important; }
    .card { border: none; box-shadow: none; padding: 0; }
    .main { padding: 0; overflow: visible; opacity: 1; }
    body { background: white; height: auto; overflow: visible; font-size: 12pt; }
    .page-section { display: none; }
    .page-section.active { display: block; }
    table { width: 100%; border: 1px solid #ddd; border-collapse: collapse; }
    th, td { border: 1px solid #ddd; font-size: 10pt; }
    input { border: none; background: transparent; }
    .print-header { display: block !important; text-align: center; margin-bottom: 20px; border-bottom: 2px solid #333; padding-bottom: 10px; }
    .detail-display { display: block !important; border: none; padding: 0; }
    .bank-grid { display: block; }
    .bank-col:first-child { display: none; }
    .loan-card { background: white !important; color: #333 !important; box-shadow: none !important; border: 1px solid #333 !important; }
    /* สไตล์สำหรับการพิมพ์รายงานเงินกู้ยืม */
    #page-loan-report .header-row { border-bottom: 3px solid #000; margin-bottom: 15px; padding-bottom: 10px; }
    #page-loan-report h3, #page-loan-report h4 { color: #000 !important; font-weight: bold; }
    #page-loan-report table { border: 1px solid #000; margin-bottom: 20px; }
    #page-loan-report th { background: #f0f0f0 !important; border: 1px solid #000; padding: 8px; font-weight: bold; color: #000 !important; }
    #page-loan-report td { border: 1px solid #ccc; padding: 6px 8px; }
    #page-loan-report tfoot tr { background: #e8e8e8 !important; border-top: 2px solid #000; font-weight: bold; }
    #page-loan-report tfoot td { padding: 10px 8px; }
}
