:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #0d9488;
    --accent: #f59e0b;
    --gradient-1: linear-gradient(135deg, #4f46e5, #7c3aed);
    --gradient-2: linear-gradient(135deg, #0d9488, #0891b2);
    --gradient-3: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-4: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bs-body-font-family: 'Outfit', 'Segoe UI', sans-serif;
}

body {
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    overflow-x: hidden;
    background: #f8fafc;
    color: #1e293b;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body, header, aside, .card, .card-header, .card-footer, .table, .form-control, .form-select,
.modal-content, .modal-header, .modal-footer, .nav-tabs .nav-link, .list-group-item,
.stat-card, .badge, .alert, .progress, .dropdown-menu,
.menu-item-active, .menu-item-inactive, .menu-dropdown-item-active, .menu-dropdown-item-inactive {
    transition-property: background-color, color, border-color, box-shadow;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

/* ── Sidebar tighten spacing ── */
.menu-item {
    padding-block: 6px !important;
    gap: 10px !important;
}

.menu-dropdown-item {
    padding-block: 5px !important;
    gap: 10px !important;
}

/* ── Sidebar smooth transition ── */
#sidebar {
    will-change: width;
    overflow: hidden;
}

#sidebar .menu-item-text {
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.3s ease;
}

#sidebar h2 span,
#sidebar h2 i {
    white-space: nowrap;
}

.menu-dropdown-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Content offset for fixed sidebar (not in pre-built Tailwind) ── */
/* Sidebar widths and content margins — match our sidebar w-[280px]/w-[80px] */
.w-\[280px\] { width: 280px; }
.w-\[80px\]  { width: 80px; }

@media (min-width: 1280px) {
    .xl\:ml-\[280px\] { margin-left: 280px; }
    .xl\:ml-\[80px\]  { margin-left: 80px; }
    .xl\:hidden { display: none; }
    .xl\:flex { display: flex; }
    .xl\:block { display: block; }
    .xl\:translate-x-0 { transform: translateX(0); }
}

@media (max-width: 1279px) {
    .ml-0 { margin-left: 0; }
    .xl\:hidden { display: none; }
    .xl\:flex { display: none; }
}

#sidebar h2 {
    font-size: 0.7rem !important;
    letter-spacing: 0.05em;
    margin-bottom: 6px !important;
    padding-bottom: 6px !important;
    border-bottom: 1px solid #e2e8f0;
    opacity: 0.5;
    font-weight: 700 !important;
}

.dark #sidebar h2 {
    border-bottom-color: #1e293b;
}

.form-control[readonly] {
    background-color: #f1f5f9;
    cursor: not-allowed;
}

/* ── Typography ── */
h4, h5, h6 {
    color: #1e293b;
    font-weight: 700;
}

/* ── Cards ── */
.card {
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.06);
    transition: all .2s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
}

.card-header {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-weight: 600;
    color: #1e293b;
    border-radius: 12px 12px 0 0 !important;
    padding: 0.75rem 1rem;
}

.card.border-0 {
    border: none !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Tables inside zero-padding cards ── */
.card-body.p-0 > .table-responsive {
    padding: 0 0.5rem 0.25rem;
}

.card-body.p-0 > .table-responsive > .table > thead > tr > th:first-child,
.card-body.p-0 > .table-responsive > .table > tbody > tr > td:first-child {
    padding-left: 1rem;
}

.card-body.p-0 > .table-responsive > .table > thead > tr > th:last-child,
.card-body.p-0 > .table-responsive > .table > tbody > tr > td:last-child {
    padding-right: 1rem;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: 14px;
    padding: 22px 24px;
    color: #fff;
    transition: all .3s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,.08);
    border-radius: 50%;
    transform: scale(0);
    transition: transform .4s;
}

.stat-card:hover::before {
    transform: scale(1);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,.15);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
    position: absolute;
    right: 16px;
    bottom: 12px;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    opacity: .9;
    margin-top: 2px;
}

.bg-primary { background: var(--gradient-1) !important; }
.bg-success { background: var(--gradient-2) !important; }
.bg-warning { background: linear-gradient(135deg, #f59e0b, #d97706) !important; }
.bg-danger { background: linear-gradient(135deg, #ef4444, #dc2626) !important; }
.bg-info { background: linear-gradient(135deg, #06b6d4, #0891b2) !important; }
.bg-secondary { background: linear-gradient(135deg, #64748b, #475569) !important; }

/* ── Tables ── */
.table th {
    font-weight: 600;
    white-space: nowrap;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom-width: 2px !important;
    border-bottom-color: #e2e8f0 !important;
    font-size: 0.8125rem;
    padding: 0.75rem 1rem;
}

.table td {
    vertical-align: middle;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #f8fafc;
}

.table-hover tbody tr:hover {
    background-color: var(--primary-light);
}

/* ── Buttons ── */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 6px 16px;
    transition: all .2s;
}

.btn-primary {
    background: var(--gradient-1);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,70,229,.4);
}

.btn-success {
    background: var(--gradient-2);
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #0f766e, #0e7490);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13,148,136,.4);
}

.btn-outline-primary {
    border-color: #4f46e5;
    color: #4f46e5;
}

.btn-outline-primary:hover {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}

/* ── Alerts ── */
.alert {
    border-radius: 10px;
    border: none;
}

.alert-info {
    background: var(--primary-light);
    color: #4338ca;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
}

/* ── Badges ── */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ── Nav Tabs ── */
.nav-tabs {
    border-bottom: 2px solid #e2e8f0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    white-space: nowrap;
}

.nav-tabs::-webkit-scrollbar {
    height: 3px;
}

.nav-tabs .nav-link {
    font-weight: 500;
    color: #64748b;
    border: none;
    padding: 8px 20px;
    transition: all .2s;
    border-radius: 8px 8px 0 0;
}

.nav-tabs .nav-link:hover {
    color: #4f46e5;
    background: var(--primary-light);
}

.nav-tabs .nav-link.active {
    color: #4f46e5;
    background: transparent;
    border-bottom: 2px solid #4f46e5;
    font-weight: 600;
}

/* ── Forms ── */
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #e2e8f0;
    transition: all .2s;
}

.form-control:focus, .form-select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.form-label {
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

/* ── Modals ── */
.modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    font-weight: 600;
    border-radius: 14px 14px 0 0;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    border-radius: 0 0 14px 14px;
}

/* ── Progress Bar ── */
.progress {
    border-radius: 10px;
    background: #f1f5f9;
}

.progress-bar {
    border-radius: 10px;
}

/* ── Quick Access Buttons ── */
.btn-outline-primary, .btn-outline-success, .btn-outline-info, .btn-outline-secondary, .btn-outline-warning {
    border-width: 1.5px;
}

/* ── Soft Colors ── */
.bg-primary-soft { background: var(--primary-light); color: #4f46e5; }
.bg-success-soft { background: #ecfdf5; color: #065f46; }
.bg-warning-soft { background: #fffbeb; color: #92400e; }
.bg-danger-soft  { background: #fef2f2; color: #991b1b; }

/* ── Loading Bar ── */
#loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
}

#loading-bar.active {
    opacity: 1;
}

#loading-bar .loading-bar-inner {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed, #06b6d4);
    border-radius: 0 2px 2px 0;
    animation: loading-bar-progress 2s ease-in-out infinite;
}

@keyframes loading-bar-progress {
    0%   { width: 0; margin-left: 0; }
    50%  { width: 70%; margin-left: 15%; }
    100% { width: 0; margin-left: 100%; }
}

/* ── Toast ── */
.toast-container {
    z-index: 9999;
}

.toast {
    border-radius: 10px;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Login ── */
.login-container {
    max-width: 420px;
    margin: 80px auto;
}

.login-container .card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.1);
}

.login-container .card-header {
    background: var(--gradient-1);
    color: #fff;
    text-align: center;
    border-radius: 16px 16px 0 0 !important;
    padding: 24px;
}

.login-container .card-header h4 {
    color: #fff;
    margin: 0;
}

/* ── Notifications ── */
#notif-dropdown {
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

#notif-dropdown .dropdown-item {
    border-radius: 8px;
    padding: 8px 12px;
    transition: background .15s;
}

#notif-dropdown .dropdown-item:hover {
    background: var(--primary-light);
}

/* ── Misc ── */
.alert .btn {
    border-radius: 6px;
}

.page-header {
    padding-bottom: 12px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e2e8f0;
}

.text-muted {
    color: #94a3b8 !important;
}

/* ── Print Leave ── */
.badge-success { background: #059669 !important; }
.badge-warning { background: #d97706 !important; }
.badge-danger { background: #dc2626 !important; }
.badge-info { background: #0891b2 !important; }
.badge-secondary { background: #64748b !important; }

/* ── Dark Mode ── */
.dark {
    --primary-light: #1e2340;
}

.dark body {
    background: #0f172a;
    color: #e2e8f0;
}

.dark #sidebar,
.dark aside#sidebar {
    background-color: #0f172a !important;
    border-right-color: #1e293b !important;
    color: #e2e8f0;
}

.dark header {
    background-color: #111827 !important;
    border-bottom-color: #1e293b !important;
}

/* Header action buttons — remove Bootstrap border reset */
header .rounded-full,
header button.rounded-full,
header .rounded-lg,
header button.rounded-lg {
    border: none !important;
}

.dark .menu-item-active {
    background-color: rgba(70, 95, 255, 0.12);
    color: #818cf8;
}

.dark .menu-item-inactive {
    color: #94a3b8;
}

.dark .menu-item-inactive:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: #e2e8f0;
}

.dark .menu-dropdown-item-active {
    color: #818cf8;
}

.dark .menu-dropdown-item-inactive {
    color: #94a3b8;
}

.dark .menu-dropdown-item-inactive:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: #e2e8f0;
}

.dark .card {
    background: #1e293b;
    border-color: #334155;
}

.dark .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

.dark .card-header {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.dark .card-footer {
    background: #1e293b;
    border-color: #334155;
}

.dark h4, .dark h5, .dark h6 {
    color: #f1f5f9;
}

.dark .table {
    color: #e2e8f0 !important;
}

.dark .table th {
    color: #94a3b8 !important;
    border-bottom-color: #334155 !important;
    background-color: #1e293b !important;
}

.dark .table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
    background-color: #1a2332 !important;
}

.dark .table-striped > tbody > tr:nth-of-type(odd) td {
    background-color: #1e293b !important;
}

.dark .table-striped > tbody > tr:nth-of-type(even) td {
    background-color: #1a2332 !important;
}

.dark .table-hover tbody tr:hover td {
    background-color: #334155 !important;
}

.dark .table-light,
.dark .table > :not(caption) > * > * {
    color: #e2e8f0 !important;
    background-color: transparent !important;
}

.dark .table small,
.dark .table code,
.dark .table span,
.dark .table strong,
.dark .table a {
    color: inherit !important;
}

.dark .form-control, .dark .form-select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

.dark .form-control:focus, .dark .form-select:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129,140,248,.2);
}

.dark .form-control[readonly] {
    background-color: #1e293b;
}

.dark .form-label {
    color: #94a3b8;
}

.dark .modal-content {
    background: #1e293b;
}

.dark .modal-header {
    border-color: #334155;
    color: #f1f5f9;
}

.dark .modal-footer {
    border-color: #334155;
}

.dark .modal-backdrop.show {
    opacity: .7;
}

.dark .nav-tabs {
    border-color: #334155;
}

.dark .nav-tabs .nav-link {
    color: #94a3b8;
}

.dark .nav-tabs .nav-link:hover {
    color: #818cf8;
    background: rgba(129,140,248,.1);
}

.dark .nav-tabs .nav-link.active {
    color: #818cf8;
    border-color: #818cf8;
}

.dark .alert-info {
    background: rgba(99,102,241,.15);
    color: #a5b4fc;
}

.dark .alert-success {
    background: rgba(5,150,105,.15);
    color: #6ee7b7;
}

.dark .alert-warning {
    background: rgba(245,158,11,.15);
    color: #fcd34d;
}

.dark .alert-danger {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
}

.dark .text-muted {
    color: #64748b !important;
}

.dark .page-header {
    border-color: #334155;
}

.dark .progress {
    background: #334155;
}

.dark #notif-dropdown {
    background: #1e293b;
}

.dark #notif-dropdown .dropdown-item {
    color: #e2e8f0;
}

.dark #notif-dropdown .dropdown-item:hover {
    background: #334155;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.dark .dropdown-menu {
    background: #1e293b;
    border-color: #334155;
}

.dark .dropdown-item {
    color: #e2e8f0;
}

.dark .dropdown-item:hover {
    background: #334155;
    color: #fff;
}

.dark .dropdown-divider {
    border-color: #334155;
}

.dark .bg-primary-soft { background: rgba(79,70,229,.2); color: #a5b4fc; }
.dark .bg-success-soft { background: rgba(5,150,105,.15); color: #6ee7b7; }
.dark .bg-warning-soft { background: rgba(245,158,11,.15); color: #fcd34d; }
.dark .bg-danger-soft  { background: rgba(239,68,68,.15); color: #fca5a5; }

.dark .breadcrumb-item a {
    color: #adb5bd;
}
.dark .breadcrumb-item a:hover {
    color: #86b7fe;
}
.dark .breadcrumb-item.active {
    color: #86b7fe;
}
.dark .breadcrumb-item + .breadcrumb-item::before {
    color: #6c757d;
}

@media (max-width: 768px) {
    aside#sidebar {
        transform: translateX(-100%);
    }
    aside#sidebar.mobile-open {
        transform: translateX(0);
    }
}

/* ── Content layout fixes ── */
/* Main content area behind sidebar needs consistent spacing */
.p-4 { padding: 1rem; }
@media (min-width: 768px) {
    .md\:p-6 { padding: 1.5rem; }
}

/* Tables — consistent width, alignment, and spacing */
.table-responsive {
    border-radius: 0 0 12px 12px;
}

.table th {
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    padding: 0.625rem 0.75rem;
    white-space: nowrap;
    vertical-align: middle;
}

.table td {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

/* Fix table text alignment */
.table td.text-end,
.table th.text-end { text-align: right; }
.table td.text-center,
.table th.text-center { text-align: center; }

/* Nav tabs — scrollable for many items */
.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
    gap: 0;
}

.nav-tabs::-webkit-scrollbar { height: 3px; }

.nav-tabs .nav-link {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 0.8125rem;
}

/* Card + table spacing */
.card .card-body + .table-responsive { margin-top: -0.5rem; }

/* Row/grid alignment */
.row { --bs-gutter-x: 1rem; }
.row > [class*="col-"] { padding-left: 0.5rem; padding-right: 0.5rem; }

/* Form alignment in cards */
.card .form-label { margin-bottom: 0.25rem; }
.card .mb-3 { margin-bottom: 0.75rem !important; }

/* Stat cards spacing */
.stat-card + .stat-card { margin-top: 0; }

/* Missing responsive classes */
@media (min-width: 1024px) {
    .lg\:flex-row { flex-direction: row; }
    .lg\:grid { display: grid; }
    .lg\:h-11 { height: 2.75rem; }
    .lg\:py-4 { padding-top: 1rem; padding-bottom: 1rem; }
    .lg\:w-1\/2 { width: 50%; }
    .lg\:w-11 { width: 2.75rem; }
}
@media (min-width: 640px) {
    .sm\:block { display: block; }
    .sm\:gap-4 { gap: 1rem; }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .sm\:mb-8 { margin-bottom: 2rem; }
    .sm\:p-0 { padding: 0; }
    .sm\:py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
    .sm\:text-start { text-align: left; }
}
@media (min-width: 1280px) {
    .xl\:flex-row { flex-direction: row; }
    .xl\:justify-end { justify-content: flex-end; }
    .xl\:justify-normal { justify-content: normal; }
    .xl\:px-0 { padding-left: 0; padding-right: 0; }
    .xl\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
    .xl\:border-b { border-bottom-width: 1px; border-bottom-style: solid; }
    .xl\:border-b-0 { border-bottom-width: 0; }
    .xl\:shadow-none { box-shadow: none; }
    .xl\:translate-x-0 { --tw-translate-x: 0; transform: translateX(0); }
}

/* ── Missing Tailwind arbitrary classes ── */
.w-\[280px\] { width: 280px; }
.w-\[80px\]  { width: 80px; }

@media (min-width: 1280px) {
    .xl\:ml-\[280px\] { margin-left: 280px; }
    .xl\:ml-\[80px\]  { margin-left: 80px; }
    .xl\:hidden { display: none; }
    .xl\:flex { display: flex; }
    .xl\:block { display: block; }
}
@media (max-width: 1279px) {
    .ml-0 { margin-left: 0; }
    .xl\:hidden { display: none; }
    .xl\:flex { display: none; }
}

/* 2xsm responsive */
@media (min-width: 250px) {
    .2xsm\:gap-3 { gap: 0.75rem; }
}
