/* ══════════════════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════════════════ */
:root {
    /* Sidebar dimensions */
    --sidebar-width: 256px;

    /* Sidebar palette */
    --sb-bg:            #0F172A;
    --sb-bg-parent:     #162032;   /* persistent band for top-level items */
    --sb-bg-submenu:    #0B1120;
    --sb-hover:         #1E293B;
    --sb-hover-parent:  #1E3A5F;   /* hover for top-level items */
    --sb-border:        rgba(255,255,255,0.06);

    /* Text */
    --sb-text-primary:  #E2E8F0;
    --sb-text-muted:    #94A3B8;
    --sb-text-sub:      #CBD5E1;

    /* Active state */
    --sb-active-bg:     #2563EB;
    --sb-active-border: #60A5FA;
    --sb-active-sub-bg: #1D4ED8;

    /* Icons */
    --sb-icon:          #94A3B8;

    /* Section accent color — overridden per-section by JS */
    --section-color:    #3B82F6;

    /* App */
    --primary:          #2563EB;
    --body-bg:          #F1F5F9;
}

html, body {
    font-family: Calibri, 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    margin: 0;
    min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR SHELL
══════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sb-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sb-border);
    transition: transform 0.25s ease;
}

/* Fullscreen mode */
body.fullscreen-mode .sidebar       { display: none !important; }
body.fullscreen-mode .main-content  { margin-left: 0 !important; width: 100% !important; }

/* ── Header / Logo ─────────────────────────────────────────────── */
.sidebar-header {
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(99,102,241,0.45);
    flex-shrink: 0;
}

/* ── Scrollable nav area ────────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.sidebar-nav::-webkit-scrollbar         { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track   { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb   { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

/* ══════════════════════════════════════════════════════════════════
   TOP-LEVEL PARENT LINKS  (e.g. "HR & Workforce", "Buying")
══════════════════════════════════════════════════════════════════ */
.sidebar-nav .nav-link {
    color: var(--sb-text-primary);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-left: 4px solid transparent;
    border-radius: 0;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    /* Top-level items always get distinct band background */
    background: var(--sb-bg-parent);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sidebar-nav .nav-link:hover {
    background: var(--sb-hover-parent);
    color: #fff;
    text-decoration: none;
}

/* Icon sizing for top-level links */
.sidebar-nav .nav-link > i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sb-icon);
    transition: color 0.18s ease;
}
.sidebar-nav .nav-link:hover > i { color: #fff; }

/* Chevron on parent items */
.sidebar-nav .nav-link.sidebar-parent { position: relative; }
.sidebar-nav .nav-link.sidebar-parent .sidebar-chevron {
    margin-left: auto;
    font-size: 11px;
    color: var(--sb-text-muted);
    transition: transform 0.22s ease, color 0.18s ease;
    flex-shrink: 0;
}
.sidebar-nav .nav-link.sidebar-parent:hover .sidebar-chevron,
.sidebar-nav .nav-link.sidebar-parent.active .sidebar-chevron { color: #fff; }
.sidebar-nav .nav-link.sidebar-parent[aria-expanded="true"] .sidebar-chevron { transform: rotate(180deg); }

/* Active top-level parent (when submenu is expanded and has active child) */
.sidebar-nav .nav-link.sidebar-parent.active {
    background: #1a2e50;
    color: #fff;
    border-left-color: #3B82F6;
}
.sidebar-nav .nav-link.sidebar-parent.active > i { color: #60A5FA; }

/* Dashboard — direct link (no children) active state */
.sidebar-nav > ul > li > .nav-link.active:not(.sidebar-parent) {
    background: var(--sb-active-bg);
    color: #fff;
    border-left-color: var(--sb-active-border);
}
.sidebar-nav > ul > li > .nav-link.active:not(.sidebar-parent) > i { color: #fff; }

/* ── Per-module icon colours ───────────────────────────────────── */
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="DASHBOARD"] > i { color: #FBBF24; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="HRMS"]      > i { color: #60A5FA; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="PURCHASE"]  > i { color: #34D399; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="MASTERS"]   > i { color: #FBBF24; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="GATE_ENTRY"]> i { color: #F97316; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="GRN"]       > i { color: #A78BFA; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="FINANCE"]   > i { color: #2DD4BF; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="APPROVAL"]  > i { color: #FB923C; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="REPORTS"]   > i { color: #F472B6; }
.sidebar-nav .nav-link.sidebar-parent[data-menu-toggle="ADMIN"]     > i { color: #F87171; }

/* ══════════════════════════════════════════════════════════════════
   SUBMENU CONTAINER
══════════════════════════════════════════════════════════════════ */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    background: var(--sb-bg-submenu);
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-submenu.show { max-height: 3200px; }

/* ── Submenu items ──────────────────────────────────────────────── */
.sidebar-submenu li .nav-link {
    padding: 8px 16px 8px 44px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sb-text-sub);
    border-left: 4px solid transparent;
    border-bottom: none;
    gap: 9px;
    /* Reset parent band — submenu items sit on the darker submenu bg */
    background: transparent;
}
.sidebar-submenu li .nav-link > i {
    font-size: 15px;
    width: 17px;
    color: var(--sb-icon);
    flex-shrink: 0;
    transition: color 0.15s ease;
}
.sidebar-submenu li .nav-link:hover {
    background: var(--sb-hover);
    color: #fff;
    border-left-color: transparent;
}
.sidebar-submenu li .nav-link:hover > i { color: #fff; }

/* Active submenu item */
.sidebar-submenu li .nav-link.active {
    background: var(--sb-active-sub-bg);
    color: #fff;
    font-weight: 600;
    border-left-color: var(--sb-active-border);
}
.sidebar-submenu li .nav-link.active > i { color: #fff; }

/* Extra indent for sub_header children */
.sidebar-submenu li .nav-link.sub-indent { padding-left: 58px; }

/* ══════════════════════════════════════════════════════════════════
   SECTION GROUP HEADERS  (ORGANIZATION SETUP, ATTENDANCE & TIME…)
══════════════════════════════════════════════════════════════════ */
.sidebar-group-hdr {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 14px 16px 5px 16px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--section-color, var(--sb-text-muted));
    pointer-events: none;
    user-select: none;
    line-height: 1;
}
/* Colored pill accent before section name */
.sidebar-group-hdr::before {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--section-color, var(--sb-text-muted));
    flex-shrink: 0;
}
/* Separator line above every section header except the first */
.sidebar-group-hdr:not(:first-child) {
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 16px;
}

/* ══════════════════════════════════════════════════════════════════
   SUB-SECTION HEADERS  (legacy, kept for backwards compat)
══════════════════════════════════════════════════════════════════ */
.sidebar-sub-hdr {
    padding: 5px 16px 3px 40px;
    pointer-events: auto;
}
.sidebar-sub-hdr-link {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sb-text-muted);
    text-decoration: none;
    transition: color 0.15s;
    width: 100%;
    padding-bottom: 2px;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}
.sidebar-sub-hdr-link:hover,
.sidebar-sub-hdr-link.active { color: var(--sb-text-primary); text-decoration: none; }
.sidebar-sub-hdr span {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sb-text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   MISC
══════════════════════════════════════════════════════════════════ */
.nav-divider {
    height: 1px;
    background: var(--sb-border);
    margin: 6px 12px;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
}

/* KPI Cards */
.kpi-card {
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E293B 0%, #334155 50%, #1E293B 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.75rem;
}

/* Tables */
.table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748B;
    font-weight: 600;
    border-bottom-width: 2px;
}

.table td {
    vertical-align: middle;
}

/* Scrollable tables */
.table-responsive {
    border-radius: 0 0 12px 12px;
}

/* Cards */
.card {
    border-radius: 12px;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.875rem;
}

/* Badge styles */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
}

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

/* Form styles */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #374151;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

/* Status badges */
.status-active { background-color: #DEF7EC; color: #03543F; }
.status-inactive { background-color: #FDE8E8; color: #9B1C1C; }
.status-pending { background-color: #FEF3C7; color: #92400E; }

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94A3B8;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Notification badge pulse */
.badge.rounded-pill.bg-danger {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Quick action cards */
.quick-action-card {
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}
.quick-action-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Smooth transitions */
.btn { transition: all 0.15s ease; }
.alert { transition: opacity 0.3s ease; }

/* Focus styles for accessibility */
a:focus-visible, .btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip to content link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 2000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* ============================================
   COMMON DESIGN STANDARDS (MDM Standard)
   ============================================ */

/* Common font for all pages — Calibri (user request 2026-06-11) */
body, .table, .form-control, .form-select, .btn, .badge, .card {
    font-family: Calibri, 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* --- MDM Standard Page Header --- */
.mdm-page-hdr {
    background: linear-gradient(135deg, #0c1a36 0%, #1d4ed8 70%, #2563eb 100%);
    border-radius: 14px;
    padding: 20px 28px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(37,99,235,0.2);
}
/* Any heading / paragraph inside the dark-blue gradient banner must be light.
   Templates using h1/h3 + .text-muted (HR Lifecycle, Attendance grid, etc.) were
   rendering dark text on the dark gradient = unreadable. */
.mdm-page-hdr h1, .mdm-page-hdr h2, .mdm-page-hdr h3,
.mdm-page-hdr h5, .mdm-page-hdr h6 { color: #fff; }
.mdm-page-hdr p, .mdm-page-hdr small,
.mdm-page-hdr .text-muted { color: rgba(255,255,255,0.85) !important; }
.mdm-page-hdr h4 {
    color: #fff;
    font-weight: 700;
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.mdm-page-hdr h4 i { font-size: 1.3rem; }
.mdm-page-hdr .badge {
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}
.mdm-page-hdr .btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    font-weight: 600;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.mdm-page-hdr .btn:hover {
    background: rgba(255,255,255,0.3);
    color: #fff;
}

/* --- MDM Standard KPI Bar --- */
.mdm-kpi-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.mdm-kpi {
    flex: 1;
    min-width: 140px;
    border-radius: 12px;
    padding: 16px 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}
.mdm-kpi::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}
.mdm-kpi .kpi-label { font-size: 0.75rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.mdm-kpi .kpi-value { font-size: 1.75rem; font-weight: 700; margin-top: 2px; }
.mdm-kpi-blue { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.mdm-kpi-green { background: linear-gradient(135deg, #059669, #10b981); }
.mdm-kpi-orange { background: linear-gradient(135deg, #d97706, #f59e0b); }
.mdm-kpi-red { background: linear-gradient(135deg, #dc2626, #ef4444); }
.mdm-kpi-purple { background: linear-gradient(135deg, #7c3aed, #8b5cf6); }
.mdm-kpi-teal { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.mdm-kpi-indigo { background: linear-gradient(135deg, #4338ca, #6366f1); }

/* ══════════════════════════════════════════════════════════════════
   GLOBAL TABLE STANDARD  —  STICKY SCROLLBAR SYSTEM
   ═══════════════════════════════════════════════════════════════════
   PROBLEM SOLVED:
     With many rows the horizontal scrollbar ends up far off-screen
     (physically at the bottom of all rows). The user has to scroll
     down → drag scrollbar → scroll back up just to see one cell.

   SOLUTION:
     Every table wrapper is a fixed-height viewport into the table.
     Both vertical (rows) and horizontal (columns) scrollbars live
     inside that viewport — always visible on screen, no matter how
     many rows there are.

   HOW IT WORKS:
     max-height: calc(100vh - var(--tbl-offset))
       = viewport height minus everything above the table on that page
     overflow: auto on BOTH axes
       = wrapper scrolls vertically (rows) AND horizontally (columns)
     thead th  position: sticky; top: 0
       = column headers stay pinned while scrolling down through rows

   ─────────────────────────────────────────────────────────────────
   RULE FOR ALL NEW PAGES — just 2 steps:
     1.  Wrap <table> in a  <div class="mdm-table-card">
     2.  Add class  mdm-table  to the <table> element
     Done — scrolling, sticky header, correct height all automatic.

   TUNING PER PAGE (if headers/filters push table lower on screen):
     In the page's <style> block add ONE line:
       :root { --tbl-offset: 420px; }
     Default 260px fits pages with just topnav + title.
     Use larger values for pages with summary cards, filter bars, tabs.

   REFERENCE OFFSETS (measure = everything above the table):
     Simple page (nav 56 + pad 16 + breadcrumb 40 + title 72) ≈ 200px  → use 220px
     + filter bar (~56px)                                              → use 280px
     + summary cards (~110px)                                          → use 390px
     + summary cards + tab row (~50px)                                 → use 440px
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --tbl-offset: 300px;   /* default — override per page if needed */
}

/* ── Shared wrapper rules ────────────────────────────────────────── */
.mdm-table-card,
[class*="-table-wrap"],
.table-responsive {
    /* Fixed-height viewport so horizontal scrollbar is always on screen */
    max-height: calc(100vh - var(--tbl-offset));
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;   /* smooth momentum scroll on touch */
    /* Scrollbar styling — thin, branded */
    scrollbar-width: thin;
    scrollbar-color: #93c5fd #f0f4ff;
}
.mdm-table-card::-webkit-scrollbar,
[class*="-table-wrap"]::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar       { width: 6px; height: 6px; }
.mdm-table-card::-webkit-scrollbar-track,
[class*="-table-wrap"]::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.mdm-table-card::-webkit-scrollbar-thumb,
[class*="-table-wrap"]::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb { background: #93c5fd; border-radius: 4px; }
.mdm-table-card::-webkit-scrollbar-thumb:hover,
[class*="-table-wrap"]::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover { background: #60a5fa; }

/* ── mdm-table-card specific ──────────────────────────────────────── */
.mdm-table-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    min-height: 280px;   /* always show at least a few rows regardless of viewport */
}

/* ── MDM Standard Table ──────────────────────────────────────────── */
.mdm-table {
    margin-bottom: 0;
    font-size: 0.85rem;
    width: 100%;
    min-width: 700px;   /* below this width, horizontal scroll kicks in */
    table-layout: auto;
}
.mdm-table thead th {
    background: linear-gradient(90deg, #0c1a36 0%, #1a2e5c 55%, #1e3a8a 100%);
    color: #93c5fd;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 11px 14px;
    border: none;
    white-space: nowrap;
    /* ── STICKY HEADER — stays pinned while scrolling down ──────── */
    position: sticky;
    top: 0;
    z-index: 3;
}
.mdm-table thead th:hover { color: #bfdbfe; cursor: pointer; }
.mdm-table tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid #f0f6ff;
    border-left: none;
    border-right: none;
    border-top: none;
    vertical-align: middle;
    color: #334155;
}
/* cycling left border accent per 9 rows */
.mdm-table tbody tr { border-left: 4px solid transparent; transition: background .1s; }
.mdm-table tbody tr:nth-child(9n+1) { border-left-color: #1d4ed8; }
.mdm-table tbody tr:nth-child(9n+2) { border-left-color: #0891b2; }
.mdm-table tbody tr:nth-child(9n+3) { border-left-color: #059669; }
.mdm-table tbody tr:nth-child(9n+4) { border-left-color: #d97706; }
.mdm-table tbody tr:nth-child(9n+5) { border-left-color: #be185d; }
.mdm-table tbody tr:nth-child(9n+6) { border-left-color: #7c3aed; }
.mdm-table tbody tr:nth-child(9n+7) { border-left-color: #2563eb; }
.mdm-table tbody tr:nth-child(9n+8) { border-left-color: #ea580c; }
.mdm-table tbody tr:nth-child(9n+9) { border-left-color: #16a34a; }
.mdm-table tbody tr:nth-child(even) td { background-color: #f8fbff; }
.mdm-table tbody tr:nth-child(odd)  td { background-color: #ffffff; }
.mdm-table tbody tr:hover td { background-color: #eff6ff !important; }
.mdm-table tbody tr td:first-child { font-weight: 600; }

/* --- MDM Standard Filter Bar --- */
.mdm-filter-bar {
    background: #fff;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border: 1px solid #e2e8f0;
}
.mdm-filter-bar .form-control,
.mdm-filter-bar .form-select {
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid #cbd5e1;
}
.mdm-filter-bar .btn {
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}
.mdm-filter-bar.filter-active {
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border-color: #93c5fd;
}

/* --- MDM Modal styling --- */
.mdm-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.mdm-modal {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 500px;
    max-width: 95%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.mdm-modal-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}
.mdm-modal-hdr h5 {
    margin: 0;
    font-weight: 700;
    color: #1e293b;
}
.mdm-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.2s;
}
.mdm-modal-close:hover { color: #ef4444; }

/* --- MDM Action Buttons in Tables --- */
.mdm-action-btn {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    border-width: 1.5px;
}

/* --- MDM Form Fields with Color Rows --- */
.mdm-form-row:nth-child(even) {
    background: #f8fafc;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 4px;
}
.mdm-form-row:nth-child(odd) {
    background: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 4px;
}

/* --- MDM Section Header (for tabbed forms) --- */
.mdm-sec-hdr {
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.mdm-sec-hdr-blue { background: linear-gradient(90deg, #dbeafe, #eff6ff); color: #1e40af; border-left: 4px solid #2563eb; }
.mdm-sec-hdr-green { background: linear-gradient(90deg, #dcfce7, #f0fdf4); color: #166534; border-left: 4px solid #16a34a; }
.mdm-sec-hdr-purple { background: linear-gradient(90deg, #ede9fe, #f5f3ff); color: #5b21b6; border-left: 4px solid #7c3aed; }
.mdm-sec-hdr-orange { background: linear-gradient(90deg, #ffedd5, #fff7ed); color: #9a3412; border-left: 4px solid #ea580c; }
.mdm-sec-hdr-red { background: linear-gradient(90deg, #fee2e2, #fef2f2); color: #991b1b; border-left: 4px solid #dc2626; }
.mdm-sec-hdr-teal { background: linear-gradient(90deg, #ccfbf1, #f0fdfa); color: #115e59; border-left: 4px solid #0d9488; }

/* ============================================
   SMART TABLE (search/sort/filter in header)
   ============================================ */

/* Toolbar above table */
.smt-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
    gap: 12px;
    flex-wrap: wrap;
}
.smt-toolbar-left { flex: 1; min-width: 200px; }
.smt-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: #64748b;
}
.smt-search-wrap {
    position: relative;
    max-width: 380px;
}
.smt-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
}
.smt-search {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 7px 12px 7px 34px;
    font-size: 0.85rem;
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.smt-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #fff;
}
.smt-row-count {
    white-space: nowrap;
    font-weight: 500;
}

/* Sortable headers */
.smt-sortable {
    user-select: none;
    position: relative;
}
.smt-sortable:hover {
    background: #162032 !important;
}
.smt-sort-icon {
    margin-left: 5px;
    font-size: 0.7rem;
    opacity: 0.4;
    vertical-align: middle;
}
.smt-sort-active {
    opacity: 1 !important;
    color: #60a5fa;
}

/* Per-column filter dropdown inside th */
.smt-filter-dd {
    display: block;
    margin-top: 5px;
}
.smt-col-filter {
    width: 100%;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.72rem;
    background: rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}
.smt-col-filter:focus {
    outline: 1px solid #60a5fa;
    background: rgba(255,255,255,0.15);
}
.smt-col-filter option {
    background: #1e293b;
    color: #fff;
}

/* When smart table is present, adjust table card border radius */
.smt-toolbar + .table-responsive .mdm-table thead th:first-child,
.smt-toolbar + .mdm-table thead th:first-child {
    border-radius: 0;
}

/* Print Styles */
@media print {
    .sidebar, .navbar, .btn, .dropdown,
    .alert-dismissible .btn-close,
    form, .no-print { display: none !important; }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    body { background: white !important; }
    .card { border: 1px solid #dee2e6 !important; box-shadow: none !important; }
    .badge { border: 1px solid currentColor !important; }

    a[href]:after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
    .table { font-size: 0.85rem; }

    @page { margin: 1.5cm; }
    h4, h5 { page-break-after: avoid; }
    table { page-break-inside: avoid; }
}

/* ══════════════════════════════════════════════════════════════════
   BOOTSTRAP 4 → 5 BADGE COMPAT (2026-06-05)
   Memo module templates use BS4 badge-* classes; BS5 dropped them,
   leaving white text on transparent = invisible badges. Define them
   once here so every legacy usage renders correctly.
══════════════════════════════════════════════════════════════════ */
.badge.badge-primary   { background-color: #2563eb; color: #fff; }
.badge.badge-secondary { background-color: #64748b; color: #fff; }
.badge.badge-success   { background-color: #16a34a; color: #fff; }
.badge.badge-danger    { background-color: #dc2626; color: #fff; }
.badge.badge-warning   { background-color: #f59e0b; color: #212529; }
.badge.badge-info      { background-color: #0891b2; color: #fff; }
.badge.badge-light     { background-color: #f1f5f9; color: #334155; }
.badge.badge-dark      { background-color: #1e293b; color: #fff; }
