/* =========================================================
   KBS WebForms Template Theme
   ใช้เป็น CSS กลางของบริษัท Korat Ban Software
   Stack หลัก: ASP.NET Web Forms + VB.NET + Bootstrap 5
   ========================================================= */

:root {
    --kbs-primary: #2563eb;
    --kbs-primary-dark: #1d4ed8;
    --kbs-primary-soft: #eff6ff;
    --kbs-success: #16a34a;
    --kbs-warning: #f59e0b;
    --kbs-danger: #dc2626;
    --kbs-info: #0891b2;
    --kbs-bg: #f5f7fb;
    --kbs-surface: #ffffff;
    --kbs-border: #e5e7eb;
    --kbs-text: #111827;
    --kbs-muted: #6b7280;
    --kbs-sidebar: #eef2f7;
    --kbs-radius: 16px;
    --kbs-shadow: 0 10px 28px rgba(15, 23, 42, .08);
    --kbs-font-th: 'Prompt', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --kbs-font-num: 'Public Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--kbs-bg);
    color: var(--kbs-text);
    font-family: var(--kbs-font-th);
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.font-num,
.num,
.kbs-num {
    font-family: var(--kbs-font-num);
    font-variant-numeric: tabular-nums;
}

.kbs-app {
    min-height: 100vh;
    display: flex;
}

.kbs-sidebar {
    width: 270px;
    min-height: 100vh;
    background: var(--kbs-sidebar);
    border-right: 1px solid var(--kbs-border);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1040;
    transition: transform .2s ease;
}

.kbs-brand {
    height: 66px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(148, 163, 184, .35);
}

.kbs-brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--kbs-primary);
    color: #fff;
    font-weight: 700;
    font-family: var(--kbs-font-num);
}

.kbs-brand-title { font-weight: 700; line-height: 1.1; }
.kbs-brand-subtitle { color: var(--kbs-muted); font-size: 12px; }

.kbs-menu { padding: 14px 12px; }
.kbs-menu-label {
    color: #8994a5;
    font-size: 12px;
    font-weight: 600;
    padding: 10px 12px 8px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.kbs-menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 12px;
    color: #1f2937;
    margin-bottom: 4px;
    transition: background .15s ease, color .15s ease;
}

.kbs-menu-link:hover,
.kbs-menu-link.active {
    background: #e9efff;
    color: var(--kbs-primary-dark);
}

.kbs-menu-link i { width: 20px; text-align: center; }

.kbs-main {
    flex: 1;
    margin-left: 270px;
    min-width: 0;
}

.kbs-topbar {
    height: 66px;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(245, 247, 251, .86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--kbs-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.kbs-toggle {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #334155;
    display: none;
    align-items: center;
    justify-content: center;
}

.kbs-toggle:hover { background: rgba(148, 163, 184, .16); }

.kbs-topbar-title { font-weight: 700; }

.kbs-update-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff;
    color: var(--kbs-muted);
    border: 1px solid var(--kbs-border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
    font-size: 12px;
}

.kbs-content {
    padding: 24px;
}

.kbs-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 18px;
}

.kbs-page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.kbs-page-subtitle {
    margin: 5px 0 0;
    color: var(--kbs-muted);
}

.kbs-card {
    background: var(--kbs-surface);
    border: 1px solid var(--kbs-border);
    border-radius: var(--kbs-radius);
    box-shadow: var(--kbs-shadow);
    padding: 18px;
}

.kbs-card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.kbs-filter-bar {
    background: #fff;
    border: 1px solid var(--kbs-border);
    border-radius: var(--kbs-radius);
    padding: 14px;
    margin-bottom: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

.kbs-btn {
    border: 0;
    border-radius: 12px;
    min-height: 40px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.kbs-btn-primary { background: var(--kbs-primary); color: #fff; }
.kbs-btn-primary:hover { background: var(--kbs-primary-dark); color: #fff; }
.kbs-btn-light { background: #f1f5f9; color: #334155; }
.kbs-btn-danger { background: var(--kbs-danger); color: #fff; }

.kbs-table-wrap {
    overflow: auto;
    border: 1px solid var(--kbs-border);
    border-radius: var(--kbs-radius);
    background: #fff;
}

.kbs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.kbs-table th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    white-space: nowrap;
}

.kbs-table th,
.kbs-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--kbs-border);
    vertical-align: middle;
}

.kbs-table tr:last-child td { border-bottom: 0; }

.kbs-empty {
    padding: 34px 18px;
    text-align: center;
    color: var(--kbs-muted);
}

.kbs-loading-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    background: rgba(15, 23, 42, .32);
}

.kbs-loading-box {
    background: #fff;
    border-radius: 18px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--kbs-shadow);
    font-weight: 600;
}

.kbs-toast-container {
    position: fixed;
    right: 18px;
    top: 82px;
    z-index: 3100;
    width: min(360px, calc(100vw - 36px));
}

.kbs-toast {
    background: #fff;
    border: 1px solid var(--kbs-border);
    border-left: 5px solid var(--kbs-primary);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--kbs-shadow);
    animation: kbsSlideIn .18s ease;
}

.kbs-toast.success { border-left-color: var(--kbs-success); }
.kbs-toast.warning { border-left-color: var(--kbs-warning); }
.kbs-toast.error { border-left-color: var(--kbs-danger); }
.kbs-toast.info { border-left-color: var(--kbs-info); }
.kbs-toast-title { font-weight: 700; margin-bottom: 2px; }
.kbs-toast-message { color: var(--kbs-muted); font-size: 13px; }

.kbs-debug-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: min(520px, calc(100vw - 32px));
    max-height: 280px;
    display: none;
    z-index: 3200;
    background: #0f172a;
    color: #dbeafe;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .35);
    overflow: hidden;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
}

.kbs-debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #111827;
    color: #fff;
    font-family: var(--kbs-font-th);
}

.kbs-debug-body {
    padding: 10px 12px;
    overflow: auto;
    max-height: 230px;
    white-space: pre-wrap;
}

.kbs-debug-line { margin-bottom: 6px; }
.kbs-debug-line.error { color: #fecaca; }
.kbs-debug-line.warn { color: #fde68a; }
.kbs-debug-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

@keyframes kbsSlideIn {
    from { transform: translateY(-8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 991.98px) {
    .kbs-sidebar { transform: translateX(-100%); }
    body.kbs-sidebar-open .kbs-sidebar { transform: translateX(0); }
    .kbs-main { margin-left: 0; }
    .kbs-toggle { display: inline-flex; }
    .kbs-content { padding: 18px; }
    .kbs-page-header { align-items: flex-start; flex-direction: column; }
}
/* assets/kbs/css/kbs-theme.css */

.kbs-app {
    min-height: 100vh;
}

.kbs-sidebar {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.kbs-brand {
    flex: 0 0 auto;
}

.kbs-menu {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 24px;
}

    /* scrollbar แบบสุภาพ */
    .kbs-menu::-webkit-scrollbar {
        width: 6px;
    }

    .kbs-menu::-webkit-scrollbar-thumb {
        background: rgba(100, 116, 139, 0.35);
        border-radius: 999px;
    }

    .kbs-menu::-webkit-scrollbar-track {
        background: transparent;
    }
.kbs-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
}

    .kbs-loading-overlay.show {
        display: flex;
    }

.kbs-loading-box {
    width: min(360px, calc(100vw - 40px));
    background: #ffffff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    text-align: center;
}

.kbs-loading-spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto 14px auto;
    border: 4px solid #e5e7eb;
    border-top-color: var(--kbs-primary, #0d6efd);
    border-radius: 50%;
    animation: kbs-spin 0.8s linear infinite;
}

.kbs-loading-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.kbs-loading-text {
    font-size: .9rem;
    color: #6b7280;
}

@keyframes kbs-spin {
    to {
        transform: rotate(360deg);
    }
}
.kbs-kpi-card {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 18px rgba(0,0,0,.06);
    border-left: 6px solid #64748b;
}

    .kbs-kpi-card::after {
        content: "";
        position: absolute;
        right: -24px;
        top: -24px;
        width: 86px;
        height: 86px;
        border-radius: 50%;
        background: rgba(100,116,139,.12);
    }

.kbs-kpi-label {
    position: relative;
    z-index: 1;
    font-size: .9rem;
    color: #64748b;
    font-weight: 600;
}

.kbs-kpi-value {
    position: relative;
    z-index: 1;
    font-size: 1.65rem;
    font-weight: 800;
    color: #111827;
}

/* Risk Color Standard */
.kbs-kpi-red {
    border-left-color: #dc3545;
}

    .kbs-kpi-red::after {
        background: rgba(220, 53, 69, .12);
    }

    .kbs-kpi-red .kbs-kpi-value {
        color: #dc3545;
    }

.kbs-kpi-orange {
    border-left-color: #fd7e14;
}

    .kbs-kpi-orange::after {
        background: rgba(253, 126, 20, .14);
    }

    .kbs-kpi-orange .kbs-kpi-value {
        color: #fd7e14;
    }

.kbs-kpi-yellow {
    border-left-color: #ffc107;
}

    .kbs-kpi-yellow::after {
        background: rgba(255, 193, 7, .18);
    }

    .kbs-kpi-yellow .kbs-kpi-value {
        color: #b58100;
    }

.kbs-kpi-green {
    border-left-color: #198754;
}

    .kbs-kpi-green::after {
        background: rgba(25, 135, 84, .12);
    }

    .kbs-kpi-green .kbs-kpi-value {
        color: #198754;
    }

.kbs-kpi-norisk {
    border-left-color: #adb5bd;
}

    .kbs-kpi-norisk::after {
        background: rgba(173, 181, 189, .18);
    }

    .kbs-kpi-norisk .kbs-kpi-value {
        color: #495057;
    }

.kbs-kpi-total {
    border-left-color: #0d6efd;
}

    .kbs-kpi-total::after {
        background: rgba(13, 110, 253, .12);
    }

    .kbs-kpi-total .kbs-kpi-value {
        color: #0d6efd;
    }
.kbs-table-risk thead th {
    font-weight: 800;
    white-space: nowrap;
    vertical-align: middle;
    border-bottom: 2px solid #e5e7eb;
}

    .kbs-table-risk thead th.kbs-th-red {
        color: #dc3545;
    }

    .kbs-table-risk thead th.kbs-th-orange {
        color: #fd7e14;
    }

    .kbs-table-risk thead th.kbs-th-yellow {
        color: #b58100;
    }

    .kbs-table-risk thead th.kbs-th-green {
        color: #198754;
    }

    .kbs-table-risk thead th.kbs-th-norisk {
        color: #495057;
    }

    .kbs-table-risk thead th.kbs-th-total {
        color: #0d6efd;
    }

.kbs-table-risk tbody td {
    vertical-align: middle;
}

    .kbs-table-risk tbody td.kbs-td-total {
        font-weight: 800;
    }
.kbs-table-risk th.kbs-th-red,
.kbs-table-risk td.kbs-td-red {
    background: rgba(220, 53, 69, .06);
}

.kbs-table-risk th.kbs-th-orange,
.kbs-table-risk td.kbs-td-orange {
    background: rgba(253, 126, 20, .07);
}

.kbs-table-risk th.kbs-th-yellow,
.kbs-table-risk td.kbs-td-yellow {
    background: rgba(255, 193, 7, .10);
}

.kbs-table-risk th.kbs-th-green,
.kbs-table-risk td.kbs-td-green {
    background: rgba(25, 135, 84, .06);
}

.kbs-table-risk th.kbs-th-norisk,
.kbs-table-risk td.kbs-td-norisk {
    background: rgba(173, 181, 189, .12);
}

.kbs-table-risk th.kbs-th-total,
.kbs-table-risk td.kbs-td-total {
    background: rgba(13, 110, 253, .07);
}
.kbs-filter-card .form-label {
    font-size: .95rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 8px;
}

.kbs-filter-card .form-select,
.kbs-filter-card .form-control {
    min-height: 48px;
    border-radius: 10px;
    border: 1.5px solid #cbd5e1;
    background-color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

    .kbs-filter-card .form-select:focus,
    .kbs-filter-card .form-control:focus {
        border-color: #0d6efd;
        box-shadow: 0 0 0 .18rem rgba(13, 110, 253, .15);
    }

.kbs-filter-card .form-check-label {
    font-weight: 700;
    color: #0f172a;
}

.kbs-filter-card .form-check-input {
    width: 1.05rem;
    height: 1.05rem;
}