:root {
    --primary: #475569;          /* slate-600 */
    --primary-dark: #1f2937;     /* gray-800 */
    --primary-light: #f1f5f9;    /* slate-100 */
    --accent: #9ca3af;           /* gray-400 */
    --bg: #f3f4f6;               /* gray-100 */
    --surface: #ffffff;
    --border: #e5e7eb;           /* gray-200 */
    --text: #1f2937;             /* gray-800 */
    --text-muted: #6b7280;       /* gray-500 */
    --sidebar-bg: #1f2937;       /* gray-800 */
    --sidebar-text: #d1d5db;     /* gray-300 */
    --sidebar-active: #374151;   /* gray-700 */
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(31, 41, 55, .04), 0 1px 3px rgba(31, 41, 55, .03);
    --shadow:    0 1px 3px rgba(31, 41, 55, .04), 0 8px 24px rgba(31, 41, 55, .05);
    --shadow-lg: 0 4px 8px rgba(31, 41, 55, .05), 0 16px 40px rgba(31, 41, 55, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =================== LAYOUT =================== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    color: var(--sidebar-text);
    padding: 18px 0 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform .25s ease;
    z-index: 1040;
    border-right: 1px solid rgba(255, 255, 255, .04);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 22px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-logo {
    width: 42px; height: 42px;
    border-radius: 11px;
    background: linear-gradient(135deg, #6b7280, #374151);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(31, 41, 55, .45);
}
.brand-logo img { width: 26px; height: 26px; filter: brightness(0) invert(1); }
.brand-name { font-weight: 700; font-size: 1rem; color: #fff; line-height: 1.1; letter-spacing: -.01em; }
.brand-sub  { font-size: .72rem; opacity: .65; margin-top: 3px; letter-spacing: .02em; }

.sidenav {
    margin-top: 10px;
    flex: 1;
    padding: 0 12px 12px;
    overflow-y: auto;
}
.sidenav .nav-section {
    color: rgba(255, 255, 255, .35);
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    padding: 16px 12px 6px;
}
.sidenav .nav-link {
    color: var(--sidebar-text);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .89rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease, padding-left .15s ease;
    position: relative;
}
.sidenav .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    opacity: .7;
    transition: opacity .15s ease;
}
.sidenav .nav-link span { flex: 1; }
.sidenav .nav-link:hover {
    background: rgba(255, 255, 255, .05);
    color: #fff;
    padding-left: 14px;
}
.sidenav .nav-link:hover i { opacity: 1; }
.sidenav .nav-link.active {
    background: linear-gradient(90deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .02));
    color: #fff;
    box-shadow: inset 2px 0 0 #d1d5db;
}
.sidenav .nav-link.active i { opacity: 1; color: #e5e7eb; }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 68px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.page-title h5 { font-weight: 600; letter-spacing: -.01em; color: var(--text); font-size: 1.05rem; }
.page-title small { font-size: .72rem; letter-spacing: .02em; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 14px 5px 5px;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid var(--border);
    transition: all .15s ease;
    cursor: pointer;
    color: inherit;
}
.user-chip:hover,
.user-chip[aria-expanded="true"] {
    background: #e5e7eb;
    border-color: #d1d5db;
}
.user-chip:focus { outline: none; box-shadow: 0 0 0 3px rgba(107, 114, 128, .22); }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 1px solid var(--border);
}
.user-name { font-size: .85rem; font-weight: 600; color: var(--text); line-height: 1.1; }
.user-meta { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.user-meta .dot { opacity: .5; margin: 0 2px; }
.user-chevron {
    color: var(--text-muted);
    font-size: .8rem;
    transition: transform .15s ease;
}
.user-chip[aria-expanded="true"] .user-chevron { transform: rotate(180deg); }

.user-dropdown {
    min-width: 240px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    margin-top: 8px !important;
}
.user-dropdown-header {
    padding: 10px 12px 6px;
    color: var(--text);
}
.user-dropdown .dropdown-item {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
}
.user-dropdown .dropdown-item:hover { background: #f3f4f6; }
.user-dropdown .dropdown-item.text-danger:hover { background: #fef2f2; color: #b91c1c !important; }
.content { padding: 24px; flex: 1; }
.footbar {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: .8rem;
}

/* =================== CARDS =================== */
.card {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    transition: box-shadow .2s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card .card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    padding: 14px 20px;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    color: var(--text);
}
.card .card-body { padding: 20px; }

/* =================== STAT CARDS =================== */
.stat-card {
    padding: 20px 22px;
    border-radius: var(--radius);
    color: #fff;
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between;
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, .12), transparent 60%);
    pointer-events: none;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .label { opacity: .92; font-size: .8rem; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.stat-card .value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; margin-top: 6px; letter-spacing: -.02em; }
.stat-card .icon { font-size: 2.2rem; opacity: .65; }

/* Grey-tone stat cards (variants kept so existing class names still work) */
.stat-blue   { background: linear-gradient(135deg, #4b5563, #1f2937); }
.stat-green  { background: linear-gradient(135deg, #6b7280, #374151); }
.stat-orange { background: linear-gradient(135deg, #9ca3af, #4b5563); }
.stat-purple { background: linear-gradient(135deg, #64748b, #334155); }
.stat-teal   { background: linear-gradient(135deg, #71717a, #3f3f46); }
.stat-pink   { background: linear-gradient(135deg, #94a3b8, #475569); }

/* =================== METRIC TILES (light cards) =================== */
.metric-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow .2s ease, transform .2s ease;
}
.metric-tile:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.metric-tile .icon-bubble {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.metric-tile .metric-label {
    font-size: .74rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    line-height: 1.1;
}
.metric-tile .metric-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 4px;
    color: var(--text);
    letter-spacing: -.02em;
}

/* =================== TABLES =================== */
.table { color: var(--text); }
.table thead th {
    background: #f3f4f6;
    border-bottom: 1px solid var(--border) !important;
    font-weight: 600;
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 12px 14px;
}
.table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.table-hover tbody tr:hover { background: #f9fafb; }
.table-borderless td, .table-borderless th { border-bottom: 0; }

/* =================== BUTTONS =================== */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 7px 14px;
    transition: all .15s ease;
}
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(31, 41, 55, .18);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    box-shadow: 0 2px 6px rgba(31, 41, 55, .3);
}
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-success { box-shadow: 0 1px 2px rgba(31, 41, 55, .12); }
.btn-danger  { box-shadow: 0 1px 2px rgba(31, 41, 55, .12); }

/* =================== FORMS =================== */
.form-label { font-weight: 500; font-size: .85rem; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-size: .9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(107, 114, 128, .18);
}
.form-control:disabled, .form-control[readonly] { background: #f3f4f6; }
.input-group-text {
    background: #f3f4f6;
    border-color: var(--border);
    color: var(--text-muted);
    font-size: .9rem;
}

/* =================== BADGES =================== */
.badge {
    font-weight: 500;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: .72rem;
    letter-spacing: .02em;
}

/* =================== ALERTS =================== */
.alert {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 12px 16px;
    font-size: .9rem;
}
.alert-success { background: #f1f5f9; color: #1f2937; border-color: #cbd5e1; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fafaf9; color: #44403c; border-color: #d6d3d1; }
.alert-info    { background: #f3f4f6; color: #1f2937; border-color: #d1d5db; }

/* =================== TABS =================== */
.nav-tabs {
    border-bottom: 1px solid var(--border);
}
.nav-tabs .nav-link {
    color: var(--text-muted);
    border: 0;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--primary); border-color: transparent; }
.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

/* =================== PROGRESS =================== */
.progress {
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar { font-weight: 600; background-color: var(--primary); }

/* =================== LIST GROUP =================== */
.list-group-item { border-color: var(--border); padding: 12px 16px; }

/* =================== LOGIN PAGE =================== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: #1f2937;
}
.login-bg {
    flex: 1.4;
    background: url('../images/fsktm-1.png') center center / cover no-repeat;
    position: relative;
}
.login-bg::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(31, 41, 55, .55), rgba(31, 41, 55, .25));
}
.login-bg .overlay {
    position: relative;
    z-index: 2;
    color: #fff;
    padding: 50px;
    height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end;
}
.login-bg .overlay h2 { font-size: 2.2rem; font-weight: 700; letter-spacing: -.02em; }
.login-bg .overlay p { opacity: .9; max-width: 480px; font-size: .98rem; line-height: 1.5; }

.login-form-side {
    flex: 1;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    /* subtle grey wash so the form panel reads as part of the grey theme */
    background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
}
.login-card { width: 100%; max-width: 420px; }
.login-card .logo-circle {
    width: 76px; height: 76px;
    background: linear-gradient(135deg, #6b7280, #1f2937);
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px;
    box-shadow: 0 8px 24px rgba(31, 41, 55, .3);
}
.login-card .logo-circle img { width: 42px; height: 42px; filter: brightness(0) invert(1); }
.login-card h3 { text-align: center; font-weight: 700; letter-spacing: -.02em; color: var(--primary-dark); }
.login-card .role-tabs {
    display: flex; background: #e5e7eb; border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.login-card .role-tabs button {
    flex: 1; border: 0; background: transparent; padding: 8px 12px;
    border-radius: 7px; font-weight: 500; color: var(--text-muted);
    font-size: .9rem; transition: all .15s ease;
}
.login-card .role-tabs button.active {
    background: var(--surface); color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* =================== DATATABLES =================== */
.dataTables_wrapper {
    font-size: .9rem;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: .85rem;
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    margin-left: 6px !important;
    font-size: .88rem !important;
    min-width: 220px;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, .18) !important;
    outline: none;
}
.dataTables_wrapper .dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: 0;
    white-space: nowrap;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_length .form-select {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 5px 2rem 5px 10px !important;
    margin: 0 !important;
    font-size: .85rem !important;
    line-height: 1.4 !important;
    min-width: 4.25rem;
    width: auto !important;
    height: auto !important;
    background-position: right .55rem center !important;
    background-size: 14px 11px !important;
}
.dataTables_wrapper .pagination .page-link {
    border-radius: 7px !important;
    margin: 0 2px;
    border-color: var(--border);
    color: var(--text);
    font-size: .85rem;
    padding: 5px 11px;
}
.dataTables_wrapper .pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.dataTables_wrapper .pagination .page-link:hover { background: var(--primary-light); color: var(--primary); }
table.dataTable.no-footer { border-bottom: 0; }
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
    cursor: pointer;
}
table.dataTable thead .no-sort.sorting,
table.dataTable thead .no-sort {
    background-image: none !important;
    cursor: default !important;
    pointer-events: none;
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before {
    background-color: var(--primary) !important;
}

/* =================== RESPONSIVE =================== */
@media (max-width: 992px) {
    .sidebar {
        position: fixed; left: 0; top: 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
}
@media (max-width: 768px) {
    .login-bg { display: none; }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stat-card .value { font-size: 1.5rem; }
}

/* =================== PRINT (Resume PDF) =================== */
@media print {
    body { background: #fff; }
    .no-print, .sidebar, .topbar, .footbar { display: none !important; }
    .main, .content { padding: 0; margin: 0; }
}
