:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4 { color: var(--text-primary); font-weight: 600; }
a { color: var(--accent); text-decoration: none; transition: 0.3s; }
a:hover { color: var(--accent-hover); }

/* Layouts */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    height: 100vh;
    max-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0 0 0;
    overflow: hidden;
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    flex-shrink: 0;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar nav {
    flex: 1 1 0%;
    min-height: 0;
    max-height: calc(100vh - 75px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 60px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.sidebar nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.nav-link {
    padding: 11px 20px;
    color: var(--text-secondary);
    display: block;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

/* Nav Submenu & Group Toggle */
.nav-group-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.nav-arrow {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.nav-submenu {
    background: rgba(15, 23, 42, 0.6);
    margin: 4px 10px;
    border-radius: 8px;
    padding: 6px 0;
    border-left: 2px solid rgba(59, 130, 246, 0.4);
}

.nav-submenu .sub-link {
    padding: 8px 16px 8px 20px;
    font-size: 0.84rem;
    color: #94a3b8;
    margin: 1px 4px;
    border-radius: 6px;
    border-right: none;
}

.nav-submenu .sub-link:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-right: none;
}

.nav-submenu .sub-link.active {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
    font-weight: 600;
    border-right: none;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    height: 70px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
}

.content-body {
    padding: 30px;
    flex: 1;
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    transition: 0.3s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Input Groups & Form Addons */
.input-group {
    position: relative;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 100%;
}

.input-group > .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    margin-bottom: 0;
}

.input-group-prepend,
.input-group-append {
    display: flex !important;
    align-items: stretch !important;
    flex-shrink: 0 !important;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    background-color: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border);
}

.input-group > .input-group-prepend > .input-group-text,
.input-group > .input-group-prepend > .btn {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group > .input-group-append > .input-group-text,
.input-group > .input-group-append > .btn {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.input-group > .form-control:not(:first-child) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

.input-group > .form-control:not(:last-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group-sm > .form-control,
.input-group-sm > .input-group-prepend > .input-group-text,
.input-group-sm > .input-group-append > .input-group-text {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    color: #fff;
}
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; transform: translateY(-2px); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; transform: translateY(-2px); color: #fff; }
.btn-info { background: #0ea5e9; color: #fff; }
.btn-info:hover { background: #0284c7; transform: translateY(-2px); color: #fff; }
.btn-secondary { background: #475569; color: #fff; }
.btn-secondary:hover { background: #334155; transform: translateY(-2px); color: #fff; }
.btn-dark { background: #0f172a; color: #fff; border: 1px solid var(--border); }
.btn-dark:hover { background: #1e293b; color: #fff; }

.btn-outline-light { background: transparent; border: 1px solid rgba(255, 255, 255, 0.25); color: #f8fafc; }
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.btn-outline-warning { background: transparent; border: 1px solid #f59e0b; color: #f59e0b; }
.btn-outline-warning:hover { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.btn-outline-primary { background: transparent; border: 1px solid #3b82f6; color: #3b82f6; }
.btn-outline-primary:hover { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.btn-outline-danger { background: transparent; border: 1px solid #ef4444; color: #ef4444; }
.btn-outline-danger:hover { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.btn-outline-info { background: transparent; border: 1px solid #0ea5e9; color: #0ea5e9; }
.btn-outline-info:hover { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.btn-outline-success { background: transparent; border: 1px solid #10b981; color: #10b981; }
.btn-outline-success:hover { background: rgba(16, 185, 129, 0.15); color: #34d399; }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

/* Tables */
.table-responsive {
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}
.table th, .table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
}
.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
}
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-primary { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.badge-secondary { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }
.badge-dark { background: rgba(15, 23, 42, 0.75); color: #94a3b8; border: 1px solid rgba(255, 255, 255, 0.15); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-info { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.4); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.4); }
.badge-default { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }
.badge-light { background: rgba(255, 255, 255, 0.15); color: #f8fafc; border: 1px solid rgba(255, 255, 255, 0.3); }
.badge-active, .badge-aktif { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-inactive, .badge-nonaktif { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.92rem;
}
.alert-success { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.4); color: #34d399; }
.alert-danger { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4); color: #f87171; }
.alert-warning { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.4); color: #fbbf24; }
.alert-info { background: rgba(14, 165, 233, 0.12); border: 1px solid rgba(14, 165, 233, 0.4); color: #38bdf8; }

/* Responsive Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}
.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}
.col-12 { flex: 0 0 auto; width: 100%; }
.col-11 { flex: 0 0 auto; width: 91.666667%; }
.col-10 { flex: 0 0 auto; width: 83.333333%; }
.col-9  { flex: 0 0 auto; width: 75%; }
.col-8  { flex: 0 0 auto; width: 66.666667%; }
.col-7  { flex: 0 0 auto; width: 58.333333%; }
.col-6  { flex: 0 0 auto; width: 50%; }
.col-5  { flex: 0 0 auto; width: 41.666667%; }
.col-4  { flex: 0 0 auto; width: 33.333333%; }
.col-3  { flex: 0 0 auto; width: 25%; }
.col-2  { flex: 0 0 auto; width: 16.666667%; }
.col-1  { flex: 0 0 auto; width: 8.333333%; }

@media (min-width: 576px) {
    .col-sm-12 { flex: 0 0 auto; width: 100%; }
    .col-sm-8  { flex: 0 0 auto; width: 66.666667%; }
    .col-sm-6  { flex: 0 0 auto; width: 50%; }
    .col-sm-4  { flex: 0 0 auto; width: 33.333333%; }
    .col-sm-3  { flex: 0 0 auto; width: 25%; }
}

@media (min-width: 768px) {
    .col-md-12 { flex: 0 0 auto; width: 100%; }
    .col-md-8  { flex: 0 0 auto; width: 66.666667%; }
    .col-md-6  { flex: 0 0 auto; width: 50%; }
    .col-md-4  { flex: 0 0 auto; width: 33.333333%; }
    .col-md-3  { flex: 0 0 auto; width: 25%; }
}

@media (min-width: 992px) {
    .col-lg-12 { flex: 0 0 auto; width: 100%; }
    .col-lg-8  { flex: 0 0 auto; width: 66.666667%; }
    .col-lg-6  { flex: 0 0 auto; width: 50%; }
    .col-lg-4  { flex: 0 0 auto; width: 33.333333%; }
    .col-lg-3  { flex: 0 0 auto; width: 25%; }
}

@media (max-width: 767.98px) {
    .col-md-6, .col-md-4, .col-md-3, .col-md-8 { width: 100% !important; }
}

/* Row Gaps */
.g-1 { margin-right: -0.25rem; margin-left: -0.25rem; }
.g-1 > * { padding-right: 0.25rem; padding-left: 0.25rem; margin-bottom: 0.5rem; }
.g-2 { margin-right: -0.5rem; margin-left: -0.5rem; }
.g-2 > * { padding-right: 0.5rem; padding-left: 0.5rem; margin-bottom: 0.75rem; }
.g-3 { margin-right: -0.75rem; margin-left: -0.75rem; }
.g-3 > * { padding-right: 0.75rem; padding-left: 0.75rem; margin-bottom: 1rem; }
.g-4 { margin-right: -1rem; margin-left: -1rem; }
.g-4 > * { padding-right: 1rem; padding-left: 1rem; margin-bottom: 1.5rem; }

/* Flex & Layout Utilities */
.d-flex { display: flex !important; }
.d-inline { display: inline-block !important; }
.d-inline-block { display: inline-block !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.align-middle { vertical-align: middle !important; }
.text-nowrap { white-space: nowrap !important; }
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.h-100 { height: 100% !important; }

/* Responsive Visibility Classes */
@media (max-width: 575.98px) {
    .d-sm-none { display: none !important; }
}
@media (min-width: 576px) {
    .d-sm-block { display: block !important; }
    .d-sm-inline { display: inline !important; }
    .d-sm-inline-block { display: inline-block !important; }
    .d-sm-flex { display: flex !important; }
}
@media (max-width: 767.98px) {
    .d-md-none { display: none !important; }
}
@media (min-width: 768px) {
    .d-md-block { display: block !important; }
    .d-md-inline { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-flex { display: flex !important; }
}
@media (max-width: 991.98px) {
    .d-lg-none { display: inline-flex !important; }
}
@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-inline { display: inline !important; }
    .d-lg-flex { display: flex !important; }
}

/* Text Utilities */
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.fw-bold, .font-weight-bold { font-weight: 700 !important; }
.fs-sm, .small, small { font-size: 0.85rem !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-info { color: #38bdf8 !important; }
.text-warning { color: #fbbf24 !important; }
.text-success { color: #34d399 !important; }
.text-danger { color: #f87171 !important; }
.text-light { color: #f8fafc !important; }
.text-white { color: #ffffff !important; }
.text-secondary { color: #94a3b8 !important; }
.text-primary { color: #60a5fa !important; }
.text-dark { color: #0f172a !important; }

/* Subtle Backgrounds & Borders */
.bg-success-subtle { background-color: rgba(16, 185, 129, 0.15) !important; }
.border-success-subtle { border-color: rgba(16, 185, 129, 0.35) !important; }
.bg-primary-subtle { background-color: rgba(59, 130, 246, 0.15) !important; }
.border-primary-subtle { border-color: rgba(59, 130, 246, 0.35) !important; }
.bg-warning-subtle { background-color: rgba(245, 158, 11, 0.15) !important; }
.border-warning-subtle { border-color: rgba(245, 158, 11, 0.35) !important; }
.bg-danger-subtle { background-color: rgba(239, 68, 68, 0.15) !important; }
.border-danger-subtle { border-color: rgba(239, 68, 68, 0.35) !important; }
.bg-info-subtle { background-color: rgba(14, 165, 233, 0.15) !important; }
.border-info-subtle { border-color: rgba(14, 165, 233, 0.35) !important; }
.bg-secondary-subtle { background-color: rgba(100, 116, 139, 0.2) !important; }
.border-secondary-subtle { border-color: rgba(100, 116, 139, 0.35) !important; }

/* Spacing Helpers */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mr-3 { margin-right: 1rem !important; }
.ml-1 { margin-left: 0.25rem !important; }
.ml-2 { margin-left: 0.5rem !important; }

.border { border: 1px solid var(--border) !important; }
.rounded { border-radius: 8px !important; }
.shadow-sm { box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important; }
.shadow-lg { box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.6) !important; }

/* Positioning & Layout Helpers */
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.text-truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
.user-select-none { user-select: none !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

/* Dark Backgrounds & Borders */
.bg-dark { background-color: #0f172a !important; }
.border-secondary { border-color: #475569 !important; }
.border-info { border-color: #38bdf8 !important; }
.border-danger { border-color: #ef4444 !important; }
.border-0 { border: 0 !important; }

/* Custom Select2 Combobox Items */
.select2-loan-item, .select2-opt-item {
    transition: background 0.15s ease;
}
.select2-loan-item:hover, .select2-opt-item:hover {
    background: rgba(56, 189, 248, 0.18) !important;
}

/* Table Enhancements */
.table-dark { color: #f8fafc; }
.table-hover tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
.table-borderless th, .table-borderless td { border-bottom: none !important; }

/* Sidebar submenu */
.nav-group { position: relative; }
.nav-group-toggle { display: flex !important; justify-content: space-between; align-items: center; cursor: pointer; }
.nav-arrow { font-size: 0.75rem; opacity: 0.6; }
.nav-submenu { padding-left: 0; background: rgba(0,0,0,0.15); }
.nav-link.sub-link { padding: 8px 20px 8px 36px; font-size: 0.85rem; border-right: none; }
.nav-link.sub-link:hover, .nav-link.sub-link.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
    border-right: 2px solid var(--accent);
}
.sidebar nav { overflow-y: auto; flex: 1 1 0%; min-height: 0; }

/* Filter bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 12px;
    border: 1px solid var(--border);
}
.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-bar .filter-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.filter-bar .form-control {
    padding: 8px 12px;
    font-size: 0.85rem;
    min-width: 140px;
}
.filter-bar .btn { padding: 8px 16px; font-size: 0.85rem; }

/* Financial report styles */
.report-section {
    margin-bottom: 24px;
}
.report-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    padding: 10px 16px;
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    margin-bottom: 12px;
}
.report-total-row {
    font-weight: 700;
    background: rgba(59, 130, 246, 0.06) !important;
    border-top: 2px solid var(--accent);
}
.report-grand-total {
    font-weight: 700;
    font-size: 1.1rem;
    background: rgba(16, 185, 129, 0.1) !important;
    border-top: 3px double var(--success);
}
.report-balanced { color: var(--success); }
.report-unbalanced { color: var(--danger); }

/* Tree view for CoA */
.tree-level-1 { padding-left: 8px; font-weight: 700; }
.tree-level-2 { padding-left: 28px; font-weight: 600; }
.tree-level-3 { padding-left: 48px; font-weight: 400; }

/* Summary cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}
.summary-card .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.summary-card .value {
    font-size: 1.5rem;
    font-weight: 700;
}
.summary-card .value.positive { color: var(--success); }
.summary-card .value.negative { color: var(--danger); }
.summary-card .value.info { color: var(--accent); }

/* Journal form dynamic rows */
.journal-lines-table .form-control {
    padding: 8px 10px;
    font-size: 0.85rem;
    min-width: 100px;
}
.journal-lines-table select.form-control { min-width: 200px; }
.journal-lines-table td { padding: 6px 4px; vertical-align: middle; }

/* Modal overlay & Bootstrap compatibility */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.show { display: flex; }

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2050;
    overflow-x: hidden;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal.show, .modal.active, .modal[style*="display: flex"], .modal[style*="display: block"] {
    display: flex !important;
    justify-content: center;
    align-items: center;
}
.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 580px;
    margin: 1.5rem auto;
    pointer-events: auto;
    z-index: 2060;
}
.modal-dialog.modal-sm { max-width: 440px !important; }
.modal-dialog.modal-md { max-width: 620px !important; }
.modal-dialog.modal-lg { max-width: 900px !important; width: 94% !important; }
.modal-dialog.modal-xl { max-width: 1140px !important; width: 96% !important; }

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3rem);
}
.modal-content {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, rgba(255,255,255,0.15));
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 600px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    color: var(--text-primary, #f8fafc);
}
.modal-dialog.modal-lg .modal-content,
.modal-dialog.modal-xl .modal-content {
    max-width: 100% !important;
}

/* Modal Sheet for structured corporate/audit modals */
.modal-sheet .modal-content,
.modal-content.modal-sheet,
.modal-content.p-0 {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}
.modal-sheet .modal-header,
.modal-content.modal-sheet .modal-header {
    margin-bottom: 0 !important;
    padding: 18px 24px !important;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.1)) !important;
    flex-shrink: 0;
}
.modal-sheet .modal-body,
.modal-content.modal-sheet .modal-body {
    padding: 24px !important;
    overflow-y: auto !important;
    flex: 1 1 auto;
    max-height: calc(85vh - 140px);
}
.modal-sheet .modal-footer,
.modal-content.modal-sheet .modal-footer {
    margin-top: 0 !important;
    padding: 16px 24px !important;
    border-top: 1px solid var(--border, rgba(255,255,255,0.1)) !important;
    flex-shrink: 0;
}
.modal-sheet .modal-body::-webkit-scrollbar,
.modal-content.modal-sheet .modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-sheet .modal-body::-webkit-scrollbar-track,
.modal-content.modal-sheet .modal-body::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.4);
}
.modal-sheet .modal-body::-webkit-scrollbar-thumb,
.modal-content.modal-sheet .modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.modal-sheet .modal-body::-webkit-scrollbar-thumb:hover,
.modal-content.modal-sheet .modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.1));
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border, rgba(255,255,255,0.1));
}
.modal-close, .btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: 0.2s;
}
.modal-close:hover, .btn-close:hover { 
    color: var(--danger, #ef4444); 
    opacity: 1; 
}
.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    margin-top: 20px;
    justify-content: center;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.pagination a:hover { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ==========================================================================
   COMPREHENSIVE PROFESSIONAL MOBILE & RESPONSIVE DESIGN SYSTEM
   ========================================================================== */

/* Touch Target Minimum & Accessibility */
@media (pointer: coarse) {
    .btn, .nav-link, .form-control, .pagination a {
        min-height: 42px;
    }
}

/* Global Table Responsive Container Polish */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    margin-bottom: 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

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

.table-responsive::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 3px;
}

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

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

/* Ensure wide data tables do not wrap awkwardly on mobile */
.table-responsive > .table {
    margin-top: 0;
    margin-bottom: 0;
}
@media (max-width: 991.98px) {
    .table-responsive > .table:not(.table-sm):not(.table-compact):not(.table-borderless) {
        min-width: 580px;
    }
}

/* Tablet & Mobile Screens (<= 991.98px) */
@media (max-width: 991.98px) {
    /* App Layout */
    .app-container {
        height: 100vh;
        overflow: hidden;
        position: relative;
    }

    /* Off-canvas Sidebar Drawer */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        max-width: 82vw !important;
        height: 100vh !important;
        z-index: 1060 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease !important;
        box-shadow: none !important;
        background: #111827 !important;
        border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
    }

    .sidebar.show,
    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
        box-shadow: 15px 0 40px rgba(0, 0, 0, 0.75) !important;
    }

    /* Backdrop */
    .sidebar-backdrop {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(15, 23, 42, 0.75) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: 1055 !important;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }

    .sidebar-backdrop.show,
    body.sidebar-open .sidebar-backdrop {
        opacity: 1 !important;
        visibility: visible !important;
    }

    body.sidebar-open {
        overflow: hidden !important;
    }

    /* Main Content & Topbar */
    .main-content {
        width: 100% !important;
        height: 100vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .topbar {
        height: 60px !important;
        padding: 0 16px !important;
        position: sticky;
        top: 0;
        z-index: 100;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: rgba(30, 41, 59, 0.95);
    }

    .topbar-left {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }

    .page-title h3 {
        font-size: 1.15rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 240px;
    }

    .user-profile {
        gap: 8px !important;
    }

    .content-body {
        padding: 16px 12px !important;
    }

    /* Cards & Containers */
    .glass-card {
        padding: 18px 14px !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important;
    }

    /* Filter Bar Stacking */
    .filter-bar {
        padding: 14px !important;
        gap: 10px !important;
    }
    
    .filter-bar .filter-group {
        width: 100%;
    }

    .filter-bar .filter-group .form-control {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Summary Card Grid */
    .summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: 12px !important;
        margin-bottom: 16px !important;
    }

    .summary-card {
        padding: 14px 10px !important;
    }

    .summary-card .value {
        font-size: 1.25rem !important;
    }

    /* Header action stacking */
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap !important;
        gap: 12px !important;
    }

    /* Modals */
    .modal-dialog {
        margin: 0.75rem auto !important;
        width: calc(100% - 1.5rem) !important;
        max-width: 100% !important;
    }

    /* Mobile Pill Tabs for Detail Pages */
    .nav.nav-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding-bottom: 8px !important;
        gap: 8px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    }
    .nav.nav-tabs::-webkit-scrollbar {
        display: none;
    }
    .nav.nav-tabs li {
        flex-shrink: 0;
    }
    .nav.nav-tabs li a.btn {
        padding: 6px 14px !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        border-radius: 20px !important;
    }

    /* Mobile Header Action Row Smooth Horizontal Scroll */
    .page-header-actions,
    .d-flex.flex-wrap.gap-2.align-items-center {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .page-header-actions::-webkit-scrollbar,
    .d-flex.flex-wrap.gap-2.align-items-center::-webkit-scrollbar {
        display: none;
    }
    .page-header-actions .btn,
    .d-flex.flex-wrap.gap-2.align-items-center .btn,
    .d-flex.flex-wrap.gap-2.align-items-center form {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Column dividers fix on stacked mobile layout */
    .col-md-6[style*="border-right"] {
        border-right: none !important;
        padding-right: 15px !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
        padding-bottom: 20px !important;
        margin-bottom: 20px !important;
    }
    .col-md-6[style*="padding-left: 25px"],
    .col-md-6[style*="padding-left:25px"] {
        padding-left: 15px !important;
    }
}

/* Mobile Bottom Navigation Bar (Hidden by default / on desktop) */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 767.98px) {
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important;
        background: rgba(15, 23, 42, 0.94) !important;
        backdrop-filter: blur(16px) !important;
        -webkit-backdrop-filter: blur(16px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
        z-index: 1040 !important;
        align-items: center !important;
        justify-content: space-around !important;
        padding: 0 4px !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.45) !important;
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #94a3b8;
        text-decoration: none;
        font-size: 0.68rem;
        padding: 6px 2px;
        border: none;
        background: transparent;
        cursor: pointer;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-item i {
        font-size: 1.15rem;
        margin-bottom: 3px;
        transition: transform 0.2s ease, color 0.2s ease;
    }

    .mobile-nav-item.active, .mobile-nav-item:active {
        color: #38bdf8 !important;
        font-weight: 600;
    }

    .mobile-nav-item.active i {
        color: #38bdf8 !important;
        transform: translateY(-2px);
    }

    /* Padding bottom on main content & content-body so content isn't obscured by bottom bar */
    .main-content {
        padding-bottom: 64px !important;
    }
    .content-body {
        padding-bottom: 72px !important;
    }
}

/* Small Smartphone Screens (<= 575.98px) */
@media (max-width: 575.98px) {
    .topbar {
        padding: 0 12px !important;
    }

    .page-title h3 {
        font-size: 1.05rem !important;
        max-width: 150px;
    }

    .content-body {
        padding: 12px 8px !important;
    }

    .glass-card {
        padding: 14px 10px !important;
        border-radius: 10px !important;
    }

    /* Form Controls on iOS / Mobile: Prevent zoom on focus */
    .form-control, select.form-control, textarea.form-control {
        font-size: 16px !important;
        padding: 10px 12px !important;
    }

    /* Form rows and groups stack vertically */
    form.d-flex.flex-wrap > div {
        width: 100% !important;
        min-width: 100% !important;
        flex: 1 1 100% !important;
    }

    form.d-flex.flex-wrap .btn {
        flex: 1 1 auto;
    }

    /* Full width buttons in filter bars and mobile cards */
    .filter-bar .d-flex {
        width: 100%;
    }

    .filter-bar .d-flex .btn {
        flex: 1;
    }

    /* Notification dropdown as a mobile bottom/floating sheet */
    #notifDropdownMenu, .notif-dropdown-menu {
        position: fixed !important;
        top: 64px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
        border-radius: 12px !important;
    }

    /* Modals fit neatly on small screens */
    .modal-dialog {
        margin: 0.5rem auto !important;
        width: calc(100% - 1rem) !important;
    }

    .modal-content {
        padding: 16px 12px !important;
        border-radius: 12px !important;
    }

    .modal-header, .modal-footer {
        padding: 12px 14px !important;
    }

    .modal-sheet .modal-body, .modal-content.modal-sheet .modal-body {
        padding: 16px 12px !important;
        max-height: calc(85vh - 120px) !important;
    }

    /* KPI Summary Grids */
    .summary-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .summary-card {
        padding: 10px 8px !important;
    }

    .summary-card .label {
        font-size: 0.72rem !important;
    }

    .summary-card .value {
        font-size: 1.1rem !important;
    }

    /* Proportional Dashboard KPI Cards (2x2 Grid instead of 1 long column) */
    .hero-kpi-grid, .hero-kpi-grid.collector-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }
    .hero-kpi-card {
        padding: 0.85rem 0.8rem !important;
        border-radius: 12px !important;
    }
    .hero-kpi-card .kpi-value {
        font-size: 1.15rem !important;
    }
    .hero-kpi-card .kpi-title {
        font-size: 0.68rem !important;
    }
    .hero-kpi-card .kpi-icon-pill {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.95rem !important;
    }
    .sub-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }
    .sub-card {
        padding: 0.8rem !important;
    }
    .sub-card-value {
        font-size: 1.1rem !important;
    }

    /* Wizard steps button stacking on phone screens */
    .wizard-step .d-flex.justify-content-between {
        flex-direction: column-reverse !important;
        gap: 10px !important;
    }
    .wizard-step .d-flex.justify-content-between .btn {
        width: 100% !important;
        text-align: center !important;
        padding: 10px !important;
        font-size: 0.95rem !important;
    }

    /* Tables on mobile */
    .table th, .table td {
        padding: 10px 8px !important;
        font-size: 0.8rem !important;
    }

    /* Pagination buttons on mobile */
    .pagination a, .pagination span {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }

    /* SweetAlert Mobile Popups */
    .swal2-popup {
        width: calc(100% - 24px) !important;
        padding: 1.25rem !important;
    }
}

/* Print styles */
@media print {
    .sidebar, .topbar, .filter-bar, .btn, .no-print { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .content-body { padding: 10px; }
    .glass-card { border: 1px solid #ccc; box-shadow: none; background: #fff; color: #000; }
    .table th, .table td { color: #000; border-bottom: 1px solid #ccc; }
    body { background: #fff; color: #000; }
}

