:root {
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, sans-serif;
    --sidebar-width: 250px;
    --brand-primary: #041B18;
    --brand-teal: #00A88F;
    --brand-teal-dark: #00806D;
    --brand-accent: #00A88F;
    --brand-success: #00C896;
    --brand-danger: #EF4444;
    --brand-warning: #F5A623;

    /* Bootstrap Theme Overrides for Ipak Yuli Bank Aesthetics */
    --bs-primary: #00A88F;
    --bs-primary-rgb: 0, 168, 143;
    --bs-secondary: #64748B;
    --bs-secondary-rgb: 100, 116, 139;
    --bs-success: #00C896;
    --bs-success-rgb: 0, 200, 150;
    --bs-info: #00B4D8;
    --bs-info-rgb: 0, 180, 216;
    --bs-warning: #F5A623;
    --bs-warning-rgb: 245, 166, 35;
    --bs-danger: #EF4444;
    --bs-danger-rgb: 239, 68, 68;
    --bs-dark: #041B18;
    --bs-dark-rgb: 4, 27, 24;
    --bs-body-bg: #F4F7F6;
    --bs-body-color: #1E293B;
    --bs-border-color: rgba(0, 168, 143, 0.14);
    --bs-link-color: #00A88F;
    --bs-link-hover-color: #00806D;
}

[data-bs-theme="dark"] {
    --bs-body-bg: #071513;
    --bs-body-color: #E2E8F0;
    --bs-border-color: rgba(0, 200, 150, 0.15);
    --bs-card-bg: #0C1E1B;
    --bs-tertiary-bg: #0A1917;
}

body {
    font-family: var(--bs-font-sans-serif);
    font-size: 0.8125rem; /* Compact 13px system font size */
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, .brand-font {
    font-family: 'Outfit', sans-serif;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.92rem; }
h5 { font-size: 0.85rem; }
h6 { font-size: 0.78rem; }

.btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.form-control, .form-select, select, .input-group-text {
    font-size: 0.8125rem !important;
    padding: 0.35rem 0.65rem;
}

/* Global System Standard Font Size for ALL Select Inputs and Select2 Dropdowns */
select,
.form-select,
.form-select-sm,
.form-select-lg,
.select2-container,
.select2-container *,
.select2-dropdown,
.select2-search__field,
.select2-results__option {
    font-size: 0.8125rem !important; /* Standard 13px system font size */
}

.select2-container--bootstrap-5 .select2-selection,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    min-height: 35px !important;
    height: 35px !important;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.8125rem !important;
    line-height: 1.4 !important;
    border-radius: 0.375rem !important;
}

.select2-container--bootstrap-5 .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 27px !important;
    font-size: 0.8125rem !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    color: var(--bs-body-color) !important;
}

.select2-container--bootstrap-5 .select2-dropdown,
.select2-container--default .select2-dropdown {
    font-size: 0.8125rem !important;
    border-radius: 0.375rem !important;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2) !important;
    min-width: 100% !important;
    width: max-content !important;
    max-width: 90vw !important;
    white-space: nowrap !important;
    z-index: 10050 !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown,
.select2-container--default .select2-search--dropdown {
    width: 100% !important;
    padding: 6px 8px !important;
    box-sizing: border-box !important;
}

.select2-container--bootstrap-5 .select2-search__field,
.select2-container--default .select2-search--dropdown .select2-search__field {
    font-size: 0.8125rem !important;
    padding: 0.3rem 0.6rem !important;
    border-radius: 0.25rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.select2-container--bootstrap-5 .select2-results__option,
.select2-container--default .select2-results__option {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.8125rem !important;
    white-space: nowrap !important;
}

.select2-container--bootstrap-5 .select2-selection__arrow,
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 33px !important;
}

.table {
    font-size: 0.8rem;
}

.badge {
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* Ipak Yuli Bank Modern Button Styling */
.btn-primary {
    background: linear-gradient(135deg, #00A88F 0%, #00806D 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(0, 168, 143, 0.3) !important;
    border-radius: 50rem !important;
    transition: all 0.25s ease !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: linear-gradient(135deg, #00B89D 0%, #008C77 100%) !important;
    box-shadow: 0 6px 20px rgba(0, 168, 143, 0.45) !important;
    transform: translateY(-1.5px) !important;
}

.btn-outline-primary {
    color: #00A88F !important;
    border-color: #00A88F !important;
    border-radius: 50rem !important;
    background: transparent !important;
}
.btn-outline-primary:hover, .btn-outline-primary:active, .btn-outline-primary.active {
    background: linear-gradient(135deg, #00A88F 0%, #00806D 100%) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 4px 14px rgba(0, 168, 143, 0.25) !important;
}

.btn-warning {
    background: linear-gradient(135deg, #F5A623 0%, #E69512 100%) !important;
    border: none !important;
    color: #041B18 !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.3) !important;
    border-radius: 50rem !important;
}
.btn-warning:hover {
    background: linear-gradient(135deg, #FFB438 0%, #F5A623 100%) !important;
    box-shadow: 0 6px 18px rgba(245, 166, 35, 0.4) !important;
    transform: translateY(-1.5px) !important;
}

.bg-primary {
    background-color: #00A88F !important;
}
.bg-primary-subtle {
    background-color: rgba(0, 168, 143, 0.1) !important;
}
.text-primary {
    color: #00A88F !important;
}
.text-primary-subtle {
    color: #00806D !important;
}
.border-primary {
    border-color: #00A88F !important;
}

/* Sidebar Styling: Ipak Yuli Signature Dark Forest Teal */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    background: linear-gradient(180deg, #041916 0%, #0A2B26 100%) !important;
    box-shadow: 4px 0 24px rgba(4, 25, 22, 0.3);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    overflow: hidden;
}

.sidebar-brand {
    padding: 1rem 0.85rem;
    border-bottom: 1px solid rgba(0, 200, 150, 0.12) !important;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.sidebar-brand a {
    overflow: hidden;
}

.brand-title-box {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.sidebar-menu {
    padding: 0.75rem 0.5rem;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu .nav-header {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #648A84;
    padding: 0.75rem 0.75rem 0.25rem 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.sidebar-menu .nav-link {
    color: #A0BDB8;
    font-weight: 500;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-menu .nav-link i {
    min-width: 20px;
    font-size: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu .nav-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-menu .nav-link:hover {
    color: #00E5FF;
    background-color: rgba(0, 200, 150, 0.08) !important;
}

.sidebar-menu .nav-link.active {
    color: #ffffff !important;
    background: linear-gradient(90deg, rgba(0, 168, 143, 0.28) 0%, rgba(0, 200, 150, 0.06) 100%) !important;
    font-weight: 600;
    border-left: 3.5px solid #00C896 !important;
}
.sidebar-menu .nav-link.active i {
    color: #00C896 !important;
}

.sidebar-footer {
    padding: 0.85rem 0.75rem;
    border-top: 1px solid rgba(0, 200, 150, 0.12) !important;
    background: rgba(4, 25, 22, 0.6) !important;
    white-space: nowrap;
    overflow: hidden;
}

/* Collapsed Sidebar Styles (Icon-only Mode) */
body.sidebar-collapsed {
    --sidebar-width: 70px;
}

body.sidebar-collapsed .sidebar-brand .brand-title-box,
body.sidebar-collapsed .sidebar-menu .nav-link span,
body.sidebar-collapsed .sidebar-menu .nav-header,
body.sidebar-collapsed .sidebar-footer .btn-text-label {
    display: none !important;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 1rem 0.5rem;
}

body.sidebar-collapsed .sidebar-menu .nav-link {
    justify-content: center;
    padding: 0.65rem 0.5rem;
    gap: 0;
}

body.sidebar-collapsed .sidebar-footer {
    padding: 0.75rem 0.5rem;
}

body.sidebar-collapsed .sidebar-footer .btn {
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    margin: 0 auto;
}

body.sidebar-collapsed .sidebar-footer .btn i {
    margin-right: 0 !important;
    font-size: 1.1rem;
}

/* Main Content Wrapper */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Header Bar with Glassmorphism */
.topbar {
    height: 52px;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(0, 168, 143, 0.14) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 14px rgba(0, 40, 35, 0.04) !important;
}

[data-bs-theme="dark"] .topbar {
    background: rgba(12, 30, 27, 0.92) !important;
}

/* Responsive Mobile Layout */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
}

/* Stat Cards & General Cards */
.card {
    border-radius: 14px !important;
    border: 1px solid rgba(0, 168, 143, 0.12) !important;
    box-shadow: 0 4px 20px rgba(0, 40, 35, 0.04) !important;
    transition: all 0.25s ease;
}
.card-header.bg-primary {
    background: linear-gradient(135deg, #00A88F 0%, #00806D 100%) !important;
}

.stat-card {
    border: 1px solid rgba(0, 168, 143, 0.12) !important;
    border-radius: 14px !important;
    background: var(--bs-body-bg);
    box-shadow: 0 4px 16px rgba(0, 40, 35, 0.04) !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 168, 143, 0.14) !important;
    border-color: rgba(0, 168, 143, 0.35) !important;
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Form Inputs & Selection Controls */
.form-control, .form-select, select, .input-group-text {
    border-radius: 10px !important;
    border: 1px solid rgba(0, 168, 143, 0.2) !important;
}
.form-control:focus, .form-select:focus, select:focus {
    border-color: #00A88F !important;
    box-shadow: 0 0 0 0.25rem rgba(0, 168, 143, 0.2) !important;
}

/* Matrix Table Sticky Headers & High Contrast Styling */
.matrix-table-wrapper {
    overflow-x: auto;
    max-height: 70vh;
}

.matrix-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #0B2C27 !important;
    color: #ffffff !important;
    border-bottom: 2px solid #00C896 !important;
    vertical-align: middle;
    font-weight: 600;
}

.matrix-table th.role-col {
    z-index: 12;
    background-color: #041916 !important;
    color: #00C896 !important;
}

.matrix-table td.role-col {
    position: sticky;
    left: 0;
    z-index: 9;
    background-color: var(--bs-body-bg) !important;
    color: var(--bs-body-color) !important;
    border-right: 2px solid var(--bs-border-color) !important;
    font-weight: 600;
}

.flow-node {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid var(--brand-accent);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 12px;
}
.flow-node.risk {
    border-left-color: var(--brand-danger);
}
.flow-node.control {
    border-left-color: var(--brand-success);
}
.flow-node.decision {
    border-left-color: var(--brand-warning);
}

/* Modern Floating Toast Notification Styles */
.toast-container-custom {
    position: fixed;
    top: 76px;
    right: 24px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 420px;
    width: calc(100% - 48px);
}

.toast-modern {
    pointer-events: auto;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast-modern.toast-hiding {
    opacity: 0;
    transform: translateX(100px);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--bs-primary);
    animation: toastProgress 4s linear forwards;
}

.toast-modern.toast-success .toast-progress { background: #10b981; }
.toast-modern.toast-danger .toast-progress { background: #ef4444; }
.toast-modern.toast-warning .toast-progress { background: #f59e0b; }
.toast-modern.toast-info .toast-progress { background: #3b82f6; }

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

footer {
    margin-top: auto;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    color: var(--bs-secondary-color);
}

/* Global API Loading Animation */
#globalApiProgress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 99999;
    background: transparent;
    display: none;
    overflow: hidden;
}

#globalApiProgress .progress-bar-loader {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #3b82f6, #6366f1, #06b6d4, #3b82f6);
    background-size: 200% 100%;
    animation: apiLoadingGradient 1.2s linear infinite;
}

@keyframes apiLoadingGradient {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Full-Screen Interaction Lock Loader */
#globalFullScreenLoader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    user-select: none;
    pointer-events: all;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

#globalFullScreenLoader .loader-card {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 2rem 3rem;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    animation: loaderPulse 2s infinite ease-in-out;
}

#globalFullScreenLoader .spinner-custom {
    width: 3.2rem;
    height: 3.2rem;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top: 4px solid #3b82f6;
    border-right: 4px solid #6366f1;
    border-bottom: 4px solid #06b6d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loaderPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}
