:root {
    --ks-primary: #1b6ec2;
    --ks-primary-hover: #1861ac;
    --ks-success: #28a745;
    --ks-danger: #dc3545;
    --ks-border: #dee2e6;
    --ks-bg: #f4f7f6;
    --ks-text: #2d3436;
    --ks-fs-main: 14px;
    --ks-sidebar-width: 200px;
    --ks-sidebar-text: #465464;
}

body {
    background-color: var(--ks-bg);
    color: var(--ks-text);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--ks-fs-main);
    overflow-x: hidden;
}

/* --- UNIVERSAL TABLE ENTRY FIX --- */
.ks-table-master td,
.ks-table-master td span,
.ks-table-master td a,
.ks-table-master td .badge {
    line-height: 1.4;
    vertical-align: middle;
    font-size: var(--ks-fs-main);
}

/* Ensure the specific text-success/secondary helpers don't override the size */
.ks-table-master td .text-success,
.ks-table-master td .text-secondary {
    padding: 0;
    font-size: var(--ks-fs-main);
}

/* --- MASTER TABLE SYSTEM --- */
.ks-table-container {
    width: 100%;
    border: 1px solid var(--ks-border);
    border-radius: 8px;
    background: #fff;
    position: relative;
    font-size: var(--ks-fs-main);
}

.no-scroll {
    overflow-y: hidden;
    height: auto;
}

/* Logic: Enable scroll for 2+ entries */
.has-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 85px);
}

.fixed-scroll {
    overflow-y: auto !important;
    max-height: 720px !important;
}

.main-fixed-scroll {
    overflow-y: auto !important;
    height: 800px !important;
}

.form-fixed-scroll {
    overflow-y: auto !important;
    height: 900px !important;
}
.ks-table-master {
    margin-bottom: 0 !important;
    border-collapse: collapse;
    font-size: var(--ks-fs-main);
}

.ks-table-master thead th {
    /*position: sticky;*/
    /*top: 0;*/
    /*z-index: 10;*/
    /*background-color: #f8fafc !important;*/
    /*border-bottom: 2px solid var(--ks-border) !important;*/
    /*padding-top: 8px !important;*/
    /*padding-bottom: 8px !important;*/
    /*padding-right: 0 !important;*/
    /*padding-left: 12px;*/
    /*white-space: nowrap;*/
    /*color: #495057;*/
    /*font-size: var(--ks-fs-main);*/
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #f8fafc !important;
    border-bottom: 2px solid #dee2e6 !important;
}

/* Base TD styling */
.ks-table-master td .text-success{
    vertical-align: middle;
    padding: 8px 12px;
    white-space: nowrap;
    font-size: var(--ks-fs-main);
}

code, .ks-code-reset {
    color: #212529 !important;
    background-color: transparent !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-size: var(--ks-fs-main);
}

.ks-search-group h4,
h4.fw-bold,
h4.mb-2 {
    font-size: 14px !important;
    margin-bottom: 12px;
    line-height: 1.4;
    text-transform: uppercase;
}

.container-fluid div,
div.py-3 {
    margin-top: 0;
}
/* EDGE-TO-EDGE COLUMN FIX */
.td-edge-to-edge {
    padding: 0 !important;
    font-size: var(--ks-fs-main);
}

/* --- UPDATED BADGE BUY/SELL (EDGE-TO-EDGE) --- */
.badge-buy, .badge-sell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%; /* Spans full height of the row */
    min-height: 100%;  /* Standardizes row height */
    font-weight: 700;
    color: white !important;
    border-radius: 0 !important; /* Forces square edges for block look */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 !important;
    font-size: var(--ks-fs-main);
}

.badge-status{
    font-size: var(--ks-fs-main);
    color: var(--ks-success);
    font-weight: bold;
}
.badge-buy {
    background-color: var(--ks-success) !important;
    font-size: var(--ks-fs-main);
}

.badge-sell {
    background-color: var(--ks-danger) !important;
    font-size: var(--ks-fs-main);
}

.bg-success {
    background-color: transparent !important;
}

.bg-secondary {
    color: var(--ks-danger) !important;
    background-color: transparent !important;
}

/* --- UNIFIED SEARCH & INPUTS --- */
.ks-search-input {
    height: 35px !important;
    border: 1px solid var(--ks-border);
    border-radius: 4px;
    font-size: var(--ks-fs-main);
}

.btn-ks-primary {
    background-color: var(--ks-primary);
    border: none;
    color: white;
    font-weight: 600;
    height: 35px;
    padding: 0 15px;
    transition: all 0.2s;
    font-size: var(--ks-fs-main);
}

.btn-ks-primary:hover {
    background-color: var(--ks-primary-hover);
    transform: translateY(-1px);
    color: white;
    font-size: var(--ks-fs-main);
}

/* --- EXPORT / PDF --- */
.ks-pdf-btn {
    background-color: #8b0000 !important;
    color: white !important;
    border: none;
    height: 35px;
    padding: 0 15px;
    font-weight: 600;
}

/* --- NAVIGATION & MODALS --- */
/* Sidebar Fixed Width */
.ks-sidebar {
    min-width: 240px;
    max-width: 240px;
    min-height: 100vh; /* Full screen height */
    position: sticky;
    top: 0;

}

/* Nav Link Styling */
.ks-sidebar .nav-link {
    border-radius: 8px;
    padding: 10px 15px;
    color: #636e72;
    font-weight: 600;
    font-size: var(--ks-fs-main);
}

.ks-sidebar .nav-link.active {
    background-color: #3f8ffd;
    color: white !important;
}

.ks-sidebar .nav-link:hover:not(.active) {
    background-color: #f8f9fa;
}

.ks-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 1050;
    display: flex; align-items: center; justify-content: center;
    font-size: var(--ks-fs-main);
}

.ks-modal-card {
    background: white; border-radius: 12px; width: 320px; padding: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    font-size: var(--ks-fs-main);
}

/* --- CAIF FORM COMPONENTS --- */
.ks-form-card {
    max-width: 900px;
    margin: 2rem auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    background: #fff;
    padding: 20px;
    font-size: var(--ks-fs-main);
}

.ks-section-header {
    border-bottom: 2px solid #f0f0f0;
    margin: 25px 0 15px 0;
    color: var(--ks-primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: var(--ks-fs-main);
}

.ks-label {
    font-weight: 600;
    color: #444;
    font-size: var(--ks-fs-main);
}

.table tbody tr td,
.thead tr th {
    padding-top: 2px ;
    padding-bottom: 2px ;
    padding-right: 0 !important;
    padding-left: 12px;
    height: auto !important;
    line-height: 1 !important;
    text-wrap: nowrap !important;
}

/* --- APPROVAL PAGE --- */
.ks-approval-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    padding: 0 .25rem;
}

.ks-approval-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
    background: #fff;
    border: 1px solid var(--ks-border);
    border-radius: 8px;
    padding: .875rem 1rem;
    font-size: var(--ks-fs-main);
    transition: box-shadow .15s ease;
}

.ks-approval-card:hover {
    box-shadow: 0 3px 14px rgba(0, 0, 0, .08) !important;
}

.ks-id-thumb {
    flex-shrink: 0;
    width: 88px;
    height: 62px;
    border-radius: 6px;
    overflow: hidden;
    border: 1.5px solid var(--ks-border);
    background: var(--ks-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ks-id-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ks-id-preview-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 6px;
    box-shadow: 0 4px 32px rgba(0, 0, 0, .5);
}

.ks-id-close {
    position: absolute;
    top: .5rem;
    right: .75rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}

.ks-id-close:hover { color: #f8d7da; }

.ks-grid-pairs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .1rem .5rem;
    font-size: var(--ks-fs-main);
}

.ks-grid-pairs .k {
    font-weight: 600;
    color: #495057;
    margin-right: .25rem;
}

@media (max-width: 768px) {
    .ks-approval-card { flex-direction: column; }
    .ks-id-thumb { width: 100%; height: 120px; }
    .ks-grid-pairs { grid-template-columns: 1fr; }
    .ks-sidebar {
        position: static;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--ks-border);
        box-shadow: none;
    }

    .ks-content {
        margin-left: 0;
        width: 100%;
        padding: 10px 8px;
    }

    .ks-sidebar-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 10px 10px 8px;
    }

    .ks-nav-link { justify-content: center; }
}

.ks-app-shell { min-height: 100vh; }

.ks-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--ks-sidebar-width);
    min-width: var(--ks-sidebar-width);
    max-width: var(--ks-sidebar-width);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
    border-right: 1px solid var(--ks-border);
    box-shadow: 10px 0 22px -20px rgba(16, 24, 40, 0.45);
    z-index: 1030;
}

.ks-sidebar-brand {
    min-height: 74px;
    display: flex;
    align-items: center;
    padding: 10px 16px 12px;
    border-bottom: 1px solid var(--ks-border);
    background: rgba(255, 255, 255, 0.68);
}

.ks-brand-link { line-height: 1; }
.ks-brand-logo { max-width: 100%; object-fit: contain; }

.ks-sidebar-nav {
    gap: 8px;
    padding: 14px 10px;
}

.ks-main-nav .nav-link {
    color: var(--ks-sidebar-text);
    font-weight: 600;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.ks-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ks-main-nav .nav-link:hover {
    color: var(--ks-primary);
    background: #eaf2ff;
    border-color: #d4e4ff;
    transform: translateX(2px);
}

.ks-main-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, #4592f8, #2f76d2);
    box-shadow: 0 10px 18px -12px rgba(47, 118, 210, 0.9);
}

.ks-sidebar-footer {
    margin-top: auto;
    padding: 12px 10px;
    border-top: 1px solid var(--ks-border);
    background: rgba(255, 255, 255, 0.68);
}

.ks-logout-btn {
    height: 34px;
    border: 1px solid #d2dae3;
    border-radius: 999px;
    background-color: #fff;
    color: #4c5a66;
    font-size: 13px;
    font-weight: 600;
}

.ks-logout-btn:hover {
    background-color: #fff4f4;
    color: #b02a37;
    border-color: #f3b6bc;
}

.ks-content {
    margin-left: var(--ks-sidebar-width);
    width: calc(100% - var(--ks-sidebar-width));
    overflow-y: visible;
}

/*@media (max-width: 991.98px) {*/
/*    .ks-sidebar {*/
/*        position: static;*/
/*        width: 100%;*/
/*        min-width: 100%;*/
/*        max-width: 100%;*/
/*        border-right: 0;*/
/*        border-bottom: 1px solid var(--ks-border);*/
/*        box-shadow: none;*/
/*    }*/

/*    .ks-content {*/
/*        margin-left: 0;*/
/*        width: 100%;*/
/*        padding: 10px 8px;*/
/*    }*/

/*    .ks-sidebar-nav {*/
/*        display: grid;*/
/*        grid-template-columns: repeat(2, minmax(0, 1fr));*/
/*        gap: 8px;*/
/*        padding: 10px 10px 8px;*/
/*    }*/

/*    .ks-nav-link { justify-content: center; }*/
/*}*/

.ks-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 380px;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.13);
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 18px;
    animation: ksToastIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.ks-toast-success { background: #f0fdf4; border: 1px solid #86efac; }
.ks-toast-error   { background: #fef2f2; border: 1px solid #fca5a5; }

.ks-toast-icon { font-size: 22px; flex-shrink: 0; }
.ks-toast-success .ks-toast-icon { color: #16a34a; }
.ks-toast-error   .ks-toast-icon { color: #dc2626; }

.ks-toast-content { flex: 1; }
.ks-toast-message { font-weight: 600; font-size: 14px; }
.ks-toast-success .ks-toast-message { color: #166534; }
.ks-toast-error   .ks-toast-message { color: #991b1b; }
.ks-toast-sub { font-size: 11px; opacity: 0.65; margin-top: 2px; }
.ks-toast-success .ks-toast-sub { color: #166534; }
.ks-toast-error   .ks-toast-sub { color: #991b1b; }

.ks-toast-close {
    background: none; border: none; font-size: 20px;
    cursor: pointer; opacity: 0.45; line-height: 1;
    color: inherit; padding: 0 2px;
}
.ks-toast-close:hover { opacity: 0.8; }

/* Progress bar */
.ks-toast-bar {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    width: 100%;
    border-radius: 0 0 10px 10px;
    animation: ksBarDrain 4s linear forwards;
}
.ks-toast-success .ks-toast-bar { background: #22c55e; }
.ks-toast-error   .ks-toast-bar { background: #ef4444; }

@keyframes ksToastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(0.96); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0)     scale(1);    }
}
@keyframes ksBarDrain {
    from { width: 100%; }
    to   { width: 0%; }
}

.ks-approval-card .d-flex.flex-column.gap-1 {
    width: 130px !important;
    flex-shrink: 0 !important;
}