/* =========================================================
   P360 Core - Professional Theme
   Color Palette derived from Pinnacle Infotech brand identity
   Primary:   #1C3557  (Deep Navy Blue - from logo)
   Accent:    #2F6FAD  (Corporate Blue)
   Highlight: #4A9FD5  (Sky Blue)
   Light:     #EAF2FB  (Very light blue tint)
   Dark:      #0E1E33  (Deep dark navy for sidebar)
   Gold/CTA:  #F4A51C  (Amber/Gold for CTAs)
   Success:   #28A745
   Danger:    #DC3545
   ========================================================= */

/* ---------- CSS Variables ---------- */
:root {
    --p360-primary:        #1C3557;
    --p360-primary-dark:   #0E1E33;
    --p360-primary-light:  #2F6FAD;
    --p360-accent:         #4A9FD5;
    --p360-accent-light:   #EAF2FB;
    --p360-gold:           #F4A51C;
    --p360-gold-dark:      #D4880A;
    --p360-sidebar-bg:     #0E1E33;
    --p360-sidebar-hover:  #1C3557;
    --p360-sidebar-active: #2F6FAD;
    --p360-sidebar-text:   #A8BFCF;
    --p360-sidebar-text-active: #FFFFFF;
    --p360-topbar-bg:      #1C3557;
    --p360-topbar-height:  60px;
    --p360-sidebar-width:  240px;
    --p360-sidebar-collapsed: 64px;
    --p360-content-bg:     #F0F4F8;
    --p360-card-bg:        #FFFFFF;
    --p360-border:         #D8E4EE;
    --p360-text:           #2D3748;
    --p360-text-muted:     #718096;
    --p360-shadow:         0 2px 12px rgba(28,53,87,0.10);
    --p360-shadow-md:      0 4px 20px rgba(28,53,87,0.15);
    --p360-radius:         8px;
    --p360-radius-sm:      5px;
    --p360-radius-lg:      12px;
    --p360-transition:     all 0.25s ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--p360-text);
    background-color: var(--p360-content-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* hides body-level horizontal overflow; main content uses its own scroll */
}

a { text-decoration: none; color: var(--p360-primary-light); }
a:hover { color: var(--p360-accent); }

/* ---------- Layout Wrapper ---------- */
#p360-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#p360-sidebar {
    width: var(--p360-sidebar-width);
    min-height: 100vh;
    background: var(--p360-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    transition: var(--p360-transition);
    box-shadow: 3px 0 15px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* Sidebar Brand / Logo Area */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--p360-topbar-height);
    padding: 0 16px;
    background: var(--p360-primary-dark);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex: 1;
}

.sidebar-brand-logo img.logo-full {
    height: 34px;
    object-fit: contain;
    transition: var(--p360-transition);
}
.sidebar-brand-logo img.logo-icon {
    height: 32px;
    object-fit: contain;
    display: none;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--p360-sidebar-text);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--p360-radius-sm);
    transition: var(--p360-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Sidebar Nav */
.sidebar-nav-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav-wrapper::-webkit-scrollbar { width: 4px; }
.sidebar-nav-wrapper::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(168,191,207,0.5);
    padding: 16px 20px 6px;
    white-space: nowrap;
    overflow: hidden;
}

/* Nav Items */
.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-nav > ul > li { margin: 2px 8px; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--p360-radius-sm);
    color: var(--p360-sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--p360-transition);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

.sidebar-nav .nav-link .nav-icon {
    font-size: 18px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--p360-sidebar-text);
    transition: var(--p360-transition);
    flex-shrink: 0;
}

.sidebar-nav .nav-link .nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: var(--p360-transition);
}

.sidebar-nav .nav-link:hover {
    background: rgba(47,111,173,0.25);
    color: #fff;
}
.sidebar-nav .nav-link:hover .nav-icon { color: var(--p360-accent); }

.sidebar-nav .nav-link.active,
.sidebar-nav li.active > .nav-link {
    background: linear-gradient(90deg, var(--p360-primary-light), var(--p360-accent));
    color: #fff;
    box-shadow: 0 4px 12px rgba(47,111,173,0.35);
}
.sidebar-nav .nav-link.active .nav-icon,
.sidebar-nav li.active > .nav-link .nav-icon { color: #fff; }

/* Submenu arrow */
.nav-arrow {
    font-size: 12px;
    margin-left: auto;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}
.nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

/* Sub menu */
.sidebar-nav .sub-menu {
    list-style: none;
    margin: 2px 0 4px 34px;
    padding: 0;
    overflow: hidden;
}
.sidebar-nav .sub-menu li { margin: 1px 0; }
.sidebar-nav .sub-menu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--p360-radius-sm);
    color: rgba(168,191,207,0.85);
    font-size: 12.5px;
    font-weight: 400;
    text-decoration: none;
    transition: var(--p360-transition);
}
.sidebar-nav .sub-menu li a::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--p360-sidebar-text);
    flex-shrink: 0;
    transition: var(--p360-transition);
}
.sidebar-nav .sub-menu li a:hover {
    color: #fff;
    background: rgba(74,159,213,0.15);
}
.sidebar-nav .sub-menu li a:hover::before { background: var(--p360-accent); }
.sidebar-nav .sub-menu li a.active {
    color: var(--p360-accent);
    font-weight: 600;
}
.sidebar-nav .sub-menu li a.active::before { background: var(--p360-accent); }

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 11px;
    color: rgba(168,191,207,0.4);
    text-align: center;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

/* ---------- Collapsed Sidebar ---------- */
#p360-wrapper.sidebar-collapsed #p360-sidebar {
    width: var(--p360-sidebar-collapsed);
}
#p360-wrapper.sidebar-collapsed .sidebar-brand {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    height: auto;
    min-height: var(--p360-topbar-height);
}
#p360-wrapper.sidebar-collapsed .sidebar-brand-logo {
    flex: none;
    justify-content: center;
    width: 100%;
}
#p360-wrapper.sidebar-collapsed .sidebar-brand-logo img.logo-full { display: none; }
#p360-wrapper.sidebar-collapsed .sidebar-brand-logo img.logo-icon {
    display: block;
    height: 38px;
    width: auto;
    max-width: 52px;
    object-fit: contain;
}
#p360-wrapper.sidebar-collapsed .sidebar-toggle-btn {
    flex-shrink: 0;
}
#p360-wrapper.sidebar-collapsed .sidebar-section-title,
#p360-wrapper.sidebar-collapsed .nav-label,
#p360-wrapper.sidebar-collapsed .nav-arrow,
#p360-wrapper.sidebar-collapsed .sidebar-footer-text { opacity: 0; width: 0; overflow: hidden; }
#p360-wrapper.sidebar-collapsed .sidebar-nav > ul > li { margin: 2px 6px; }
#p360-wrapper.sidebar-collapsed .sidebar-nav .nav-link {
    padding: 10px 8px;
    justify-content: center;
}
#p360-wrapper.sidebar-collapsed .sidebar-nav .sub-menu { display: none; }
#p360-wrapper.sidebar-collapsed #p360-main {
    margin-left: var(--p360-sidebar-collapsed);
    width: calc(100% - var(--p360-sidebar-collapsed));
}

/* ============================================================
   TOPBAR
   ============================================================ */
#p360-topbar {
    position: fixed;
    top: 0;
    left: var(--p360-sidebar-width);
    right: 0;
    height: var(--p360-topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--p360-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1040;
    transition: left 0.25s ease;
    box-shadow: 0 1px 8px rgba(28,53,87,0.08);
    /* overflow must NOT be hidden — dropdown menus escape the topbar bounds */
}
#p360-wrapper.sidebar-collapsed #p360-topbar { left: var(--p360-sidebar-collapsed); }

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden; /* clips only this left section, not the topbar-right dropdown */
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
    overflow: visible; /* must be visible so dropdown escapes the flex container */
    position: relative;
}

/* Bootstrap 4 gap utility polyfill */
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }

/* Page title in topbar */
.topbar-page-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--p360-primary);
    white-space: nowrap;
    flex-shrink: 0;
    padding-right: 4px;
    border-right: 2px solid var(--p360-border);
    margin-right: 2px;
}

/* Breadcrumb */
.topbar-breadcrumb {
    font-size: 12px;
    color: var(--p360-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.topbar-breadcrumb a { color: var(--p360-text-muted); }
.topbar-breadcrumb a:hover { color: var(--p360-primary-light); }

/* Topbar icon buttons */
.topbar-icon-btn {
    background: transparent;
    border: none;
    color: var(--p360-text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--p360-transition);
    position: relative;
    text-decoration: none;
}
.topbar-icon-btn:hover {
    background: var(--p360-accent-light);
    color: var(--p360-primary);
}

/* Topbar site link badges — horizontally scrollable strip */
.topbar-site-links {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.topbar-site-links::-webkit-scrollbar { display: none; }

/* Fade-out right edge to indicate more content */
.topbar-site-links::after {
    content: '';
    position: sticky;
    right: 0;
    min-width: 24px;
    height: 100%;
    background: linear-gradient(to right, transparent, #fff);
    pointer-events: none;
    flex-shrink: 0;
}

.topbar-site-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--p360-accent-light);
    color: var(--p360-primary);
    border: 1px solid var(--p360-border);
    transition: var(--p360-transition);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
}
.topbar-site-link:hover {
    background: var(--p360-primary);
    color: #fff;
    border-color: var(--p360-primary);
    text-decoration: none;
}
.topbar-site-link i { font-size: 11px; }
.topbar-site-link span { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Topbar dropdowns — must float above all page content */
#p360-topbar .dropdown-menu {
    z-index: 1100;
    position: absolute;
    top: 100%;
}

/* Hide Bootstrap's auto caret — we use our own bx-chevron-down */
.topbar-user-btn::after { display: none !important; }

/* Rotate chevron when dropdown is open */
.topbar-user-btn[aria-expanded="true"] .user-chevron {
    transform: rotate(180deg);
}

/* User dropdown */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--p360-border);
    border-radius: 30px;
    padding: 4px 12px 4px 4px;
    cursor: pointer;
    transition: var(--p360-transition);
}
.topbar-user-btn:hover { background: var(--p360-accent-light); border-color: var(--p360-accent); }
.topbar-user-btn img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--p360-accent-light);
}
.topbar-user-btn .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--p360-text);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-user-btn .user-chevron {
    font-size: 13px;
    color: var(--p360-text-muted);
    transition: transform 0.2s ease;
    display: inline-flex;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#p360-main {
    margin-left: var(--p360-sidebar-width);
    margin-top: var(--p360-topbar-height);
    min-height: calc(100vh - var(--p360-topbar-height));
    width: calc(100% - var(--p360-sidebar-width));
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease, width 0.25s ease;
    flex: 1;
    overflow-x: hidden;
}

.p360-page-content {
    flex: 1;
    padding: 24px;
    min-width: 0; /* prevent flex blowout */
    overflow-x: hidden;
}

/* ---------- Page Header ---------- */
.p360-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.p360-page-header-left h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--p360-primary);
}

.p360-page-header-left .breadcrumb-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--p360-text-muted);
    margin-top: 3px;
}
.p360-page-header-left .breadcrumb-wrapper a { color: var(--p360-text-muted); }
.p360-page-header-left .breadcrumb-wrapper .sep { color: #ccc; }

/* ============================================================
   CARDS
   ============================================================ */
.p360-card {
    background: var(--p360-card-bg);
    border-radius: var(--p360-radius-lg);
    box-shadow: var(--p360-shadow);
    border: 1px solid var(--p360-border);
    margin-bottom: 24px;
    overflow: hidden;
}

.p360-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--p360-border);
    background: #fff;
    flex-wrap: wrap;
    gap: 10px;
}

.p360-card-header h5, .p360-card-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--p360-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.p360-card-header h5 i, .p360-card-header h6 i {
    color: var(--p360-primary-light);
    font-size: 16px;
}

.p360-card-body { padding: 20px; }

/* Stat Cards */
.p360-stat-card {
    background: #fff;
    border-radius: var(--p360-radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--p360-shadow);
    border: 1px solid var(--p360-border);
    transition: var(--p360-transition);
    margin-bottom: 24px;
}
.p360-stat-card:hover { box-shadow: var(--p360-shadow-md); transform: translateY(-2px); }

.p360-stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.p360-stat-icon.primary { background: rgba(28,53,87,0.1); color: var(--p360-primary); }
.p360-stat-icon.blue { background: rgba(74,159,213,0.15); color: var(--p360-accent); }
.p360-stat-icon.gold { background: rgba(244,165,28,0.15); color: var(--p360-gold); }
.p360-stat-icon.green { background: rgba(40,167,69,0.12); color: #28a745; }

.p360-stat-info { flex: 1; min-width: 0; }
.p360-stat-info .stat-value { font-size: 22px; font-weight: 700; color: var(--p360-primary); line-height: 1; }
.p360-stat-info .stat-label { font-size: 12px; color: var(--p360-text-muted); margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    font-weight: 600;
    font-size: 13px;
    border-radius: 6px;
    padding: 7px 18px;
    transition: var(--p360-transition);
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    line-height: 1.4;
    text-decoration: none;
}
.btn i { font-size: 14px; }

.btn-p360-primary {
    background: var(--p360-primary);
    color: #fff;
    border-color: var(--p360-primary);
}
.btn-p360-primary:hover {
    background: var(--p360-primary-light);
    border-color: var(--p360-primary-light);
    color: #fff;
    box-shadow: 0 4px 12px rgba(28,53,87,0.3);
    transform: translateY(-1px);
}

.btn-p360-accent {
    background: var(--p360-accent);
    color: #fff;
    border-color: var(--p360-accent);
}
.btn-p360-accent:hover {
    background: var(--p360-primary-light);
    border-color: var(--p360-primary-light);
    color: #fff;
    box-shadow: 0 4px 12px rgba(74,159,213,0.35);
    transform: translateY(-1px);
}

.btn-p360-gold {
    background: var(--p360-gold);
    color: #fff;
    border-color: var(--p360-gold);
}
.btn-p360-gold:hover {
    background: var(--p360-gold-dark);
    border-color: var(--p360-gold-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(244,165,28,0.35);
    transform: translateY(-1px);
}

.btn-p360-outline {
    background: transparent;
    color: var(--p360-primary);
    border-color: var(--p360-primary);
}
.btn-p360-outline:hover {
    background: var(--p360-primary);
    color: #fff;
    transform: translateY(-1px);
}

.btn-p360-ghost {
    background: var(--p360-accent-light);
    color: var(--p360-primary);
    border-color: transparent;
}
.btn-p360-ghost:hover {
    background: var(--p360-primary);
    color: #fff;
    transform: translateY(-1px);
}

.btn-p360-danger {
    background: #DC3545;
    color: #fff;
    border-color: #DC3545;
}
.btn-p360-danger:hover {
    background: #b02a37;
    border-color: #b02a37;
    box-shadow: 0 4px 12px rgba(220,53,69,0.3);
    transform: translateY(-1px);
}

.btn-p360-success {
    background: #1a9c5b;
    color: #fff;
    border-color: #1a9c5b;
}
.btn-p360-success:hover {
    background: #157a48;
    border-color: #157a48;
    box-shadow: 0 4px 12px rgba(26,156,91,0.3);
    transform: translateY(-1px);
}

/* Keep Bootstrap btn classes but override style */
.btn-primary {
    background: var(--p360-primary) !important;
    border-color: var(--p360-primary) !important;
}
.btn-primary:hover {
    background: var(--p360-primary-light) !important;
    border-color: var(--p360-primary-light) !important;
    box-shadow: 0 4px 12px rgba(28,53,87,0.25) !important;
}
.btn-success {
    background: #1a9c5b !important;
    border-color: #1a9c5b !important;
}
.btn-info {
    background: var(--p360-accent) !important;
    border-color: var(--p360-accent) !important;
}
.btn-warning {
    background: var(--p360-gold) !important;
    border-color: var(--p360-gold) !important;
    color: #fff !important;
}
.btn-dark {
    background: var(--p360-primary-dark) !important;
    border-color: var(--p360-primary-dark) !important;
}
.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 5px;
}
.btn-lg {
    padding: 10px 28px;
    font-size: 14.5px;
    border-radius: 8px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }

.form-label, label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--p360-primary);
    margin-bottom: 6px;
    display: block;
    letter-spacing: 0.2px;
}

.form-control {
    border: 1.5px solid var(--p360-border);
    border-radius: var(--p360-radius-sm);
    padding: 8px 14px;
    font-size: 13.5px;
    color: var(--p360-text);
    background: #fff;
    transition: var(--p360-transition);
    width: 100%;
    outline: none;
    box-shadow: none;
}
.form-control:focus {
    border-color: var(--p360-accent);
    box-shadow: 0 0 0 3px rgba(74,159,213,0.12);
}
.form-control::placeholder { color: #b0bac9; font-size: 13px; }

select.form-control { cursor: pointer; }

.input-group .form-control:not(:last-child) { border-right: 0; border-radius: var(--p360-radius-sm) 0 0 var(--p360-radius-sm); }
.input-group-text {
    background: var(--p360-accent-light);
    border: 1.5px solid var(--p360-border);
    color: var(--p360-primary);
    font-size: 14px;
    padding: 7px 12px;
}

/* Floating label inputs */
.p360-input-group {
    position: relative;
    margin-bottom: 18px;
}
.p360-input-group .form-control { padding-top: 14px; }
.p360-input-group label {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    font-size: 13px;
    font-weight: 500;
    color: #b0bac9;
    pointer-events: none;
    transition: var(--p360-transition);
    margin: 0;
    background: #fff;
    padding: 0 4px;
}
.p360-input-group .form-control:focus ~ label,
.p360-input-group .form-control:not(:placeholder-shown) ~ label {
    top: -1px;
    font-size: 11px;
    color: var(--p360-accent);
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    color: var(--p360-text);
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background: var(--p360-primary);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 14px;
    border: none;
    white-space: nowrap;
}
.table thead th:first-child { border-radius: var(--p360-radius-sm) 0 0 0; }
.table thead th:last-child { border-radius: 0 var(--p360-radius-sm) 0 0; }

.table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--p360-border);
    font-size: 13px;
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--p360-accent-light); }

.table-striped tbody tr:nth-of-type(odd) td { background: rgba(234,242,251,0.5); }
.table-striped tbody tr:nth-of-type(odd):hover td { background: var(--p360-accent-light); }

/* ========== DataTables: table (all tables) ========== */
table.dataTable thead th,
table.dataTable thead td {
    background: var(--p360-primary) !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 14px !important;
    border: none !important;
}
table.dataTable thead th:first-child,
table.dataTable thead td:first-child { border-radius: 8px 0 0 0; }
table.dataTable thead th:last-child,
table.dataTable thead td:last-child { border-radius: 0 8px 0 0; }
/* Sorting arrows on blue header — white and visible */
table.dataTable thead .sorting:before,
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:before,
table.dataTable thead .sorting_desc:after {
    color: rgba(255,255,255,0.7) !important;
    opacity: 1 !important;
}
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_desc:after { color: #fff !important; }
table.dataTable tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--p360-border);
    font-size: 13px;
    vertical-align: middle;
}
table.dataTable tbody tr:hover td { background: var(--p360-accent-light); }
table.dataTable.no-footer { border-bottom: 1px solid var(--p360-border); }
.dataTables_wrapper table.dataTable { margin-top: 0 !important; }

/* ========== DataTables: top row — unified toolbar (buttons + search) ========== */
.dataTables_wrapper .row:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 0;
    padding: 14px 20px;
    background: #f8f9fb;
    border-radius: 10px 10px 0 0;
    border: 1px solid var(--p360-border);
    border-bottom: none;
    gap: 12px;
}
/* Left: buttons (Excel, Column visibility) + length — only as wide as content */
.dataTables_wrapper .row:first-child > [class*="col-"]:first-child {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    flex: 0 0 auto !important;
    max-width: none !important;
    width: auto !important;
}
/* Right: search — takes remaining space, search aligned to far right */
.dataTables_wrapper .row:first-child > [class*="col-"]:last-child {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 0% !important;
    min-width: 0;
    max-width: none !important;
    width: auto !important;
}
.dataTables_wrapper .dataTables_filter {
    margin: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.dataTables_wrapper .dataTables_filter label {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--p360-text-muted);
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--p360-border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    transition: var(--p360-transition);
    width: 220px;
    max-width: 100%;
    background: #fff;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--p360-accent);
    box-shadow: 0 0 0 2px rgba(74,159,213,0.12);
}

/* Length (Show dropdown) — in button section, compact */
.dataTables_length {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--p360-text-muted);
    font-weight: 500;
}
.dataTables_length label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.dataTables_length select {
    border: 1px solid var(--p360-border);
    border-radius: 6px;
    padding: 5px 24px 5px 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--p360-text);
    cursor: pointer;
    outline: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6578' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 6px center;
    background-size: 10px;
    appearance: none;
    -webkit-appearance: none;
    min-width: 48px;
}
.dataTables_length select:hover { border-color: var(--p360-accent); }
.dataTables_length select:focus { border-color: var(--p360-accent); }

/* Button group (Excel, Column visibility) — clear, readable (no faded look) */
.dataTables_wrapper .dt-buttons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.dataTables_wrapper .dt-buttons .btn {
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border: 1.5px solid var(--p360-primary);
    background: #fff !important;
    color: var(--p360-primary) !important;
    transition: var(--p360-transition);
}
.dataTables_wrapper .dt-buttons .btn:hover {
    background: var(--p360-primary) !important;
    border-color: var(--p360-primary);
    color: #fff !important;
}
/* Dropdown for Column visibility */
.dataTables_wrapper .dt-buttons .dropdown-menu {
    z-index: 1060;
    border-radius: 8px;
    border: 1px solid var(--p360-border);
    box-shadow: 0 8px 24px rgba(28,53,87,0.12);
}
.dataTables_wrapper .dt-buttons .dropdown-item {
    font-size: 13px;
    padding: 8px 14px;
}
/* Table container: border under toolbar so one card look */
.dataTables_wrapper .dataTables_scrollBody table.dataTable,
.dataTables_wrapper table.dataTable {
    border: 1px solid var(--p360-border);
    border-top: none;
    border-radius: 0 0 10px 10px;
}
.dataTables_wrapper .dataTables_scrollHead table.dataTable {
    border-top: none;
}

/* ========== DataTables: bottom bar (pagination) ========== */
.dataTables_wrapper .row:last-child {
    margin-top: 16px;
    padding: 14px 20px;
    background: #f8f9fb;
    border-radius: 10px;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border: none;
    box-shadow: 0 1px 2px rgba(28,53,87,0.06);
}
/* First column: Show dropdown (marking area) + "Showing X to Y..." */
.dataTables_wrapper .row:last-child > [class*="col-"]:first-child {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}
.dataTables_wrapper .row:last-child > [class*="col-"]:last-child {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    min-width: 0;
}

/* Info text — left of bar */
.dataTables_info {
    font-size: 13px !important;
    color: var(--p360-text-muted) !important;
    font-weight: 500 !important;
    padding: 0 !important;
}

/* Pagination — right-aligned, minimal gap between buttons */
.dataTables_paginate {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-wrap: wrap;
    margin: 0 !important;
    justify-content: flex-end;
}
.dataTables_paginate .paginate_button {
    border-radius: 4px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    padding: 6px 11px !important;
    min-width: 32px;
    text-align: center;
    border: none !important;
    background: transparent !important;
    color: var(--p360-text-muted) !important;
    transition: all 0.2s ease !important;
    line-height: 1.3 !important;
    text-decoration: none !important;
    box-shadow: none !important;
}
.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover {
    background: var(--p360-primary) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 1px 3px rgba(28,53,87,0.25) !important;
}
.dataTables_paginate .paginate_button:not(.current):not(.disabled):hover {
    background: var(--p360-accent-light) !important;
    color: var(--p360-primary) !important;
}
.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover {
    cursor: not-allowed !important;
    background: transparent !important;
    color: #c5cbd6 !important;
}
.dataTables_paginate .paginate_button.previous,
.dataTables_paginate .paginate_button.next {
    font-size: 13px !important;
    padding: 6px 12px !important;
}

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */
.p360-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.p360-badge-primary { background: rgba(28,53,87,0.12); color: var(--p360-primary); }
.p360-badge-blue { background: rgba(74,159,213,0.15); color: #1a6da8; }
.p360-badge-gold { background: rgba(244,165,28,0.15); color: #9a6600; }
.p360-badge-green { background: rgba(26,156,91,0.15); color: #155a38; }
.p360-badge-red { background: rgba(220,53,69,0.12); color: #9a1c2a; }
.p360-badge-gray { background: rgba(113,128,150,0.15); color: #4a5568; }

/* ============================================================
   ALERTS / NOTIFICATIONS
   ============================================================ */
.p360-alert {
    border-radius: var(--p360-radius);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    border-left: 4px solid transparent;
    font-size: 13.5px;
}
.p360-alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.p360-alert-success { background: rgba(26,156,91,0.08); border-color: #1a9c5b; color: #155a38; }
.p360-alert-success i { color: #1a9c5b; }
.p360-alert-info { background: rgba(74,159,213,0.08); border-color: var(--p360-accent); color: #1a5f8a; }
.p360-alert-info i { color: var(--p360-accent); }
.p360-alert-warning { background: rgba(244,165,28,0.08); border-color: var(--p360-gold); color: #7a5200; }
.p360-alert-warning i { color: var(--p360-gold); }
.p360-alert-danger { background: rgba(220,53,69,0.08); border-color: #dc3545; color: #7a1520; }
.p360-alert-danger i { color: #dc3545; }

/* ============================================================
   FOOTER
   ============================================================ */
.p360-footer {
    background: #fff;
    border-top: 1px solid var(--p360-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--p360-text-muted);
    flex-wrap: wrap;
    gap: 8px;
}
.p360-footer .footer-brand { font-weight: 600; color: var(--p360-primary); }
.p360-footer a { color: var(--p360-primary-light); }

/* ============================================================
   RIGHT SIDEBAR (Settings Panel)
   ============================================================ */
#p360-right-sidebar {
    position: fixed;
    right: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(28,53,87,0.12);
    z-index: 1060;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}
#p360-right-sidebar.open { right: 0; }

.right-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--p360-border);
    background: var(--p360-primary);
    color: #fff;
}
.right-sidebar-header h6 { margin: 0; font-size: 14px; font-weight: 700; color: #fff; }
.right-sidebar-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--p360-transition);
}
.right-sidebar-close:hover { background: rgba(255,255,255,0.3); }

.right-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.right-sidebar-body .section-subtitle {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--p360-text-muted);
    margin-bottom: 12px;
}

/* Dashboard toggle checkboxes */
.dash-toggle-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f4f8;
    font-size: 13px;
    color: var(--p360-text);
}
.dash-toggle-item:last-child { border-bottom: none; }
.dash-toggle-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--p360-primary-light);
    cursor: pointer;
}

/* Right sidebar overlay */
.right-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14,30,51,0.3);
    z-index: 1055;
    display: none;
    backdrop-filter: blur(2px);
}
.right-sidebar-overlay.active { display: block; }

/* ============================================================
   MODAL Improvements — ensure modals sit above sidebar/topbar/overlays
   ============================================================ */
.modal-backdrop {
    z-index: 1110 !important;
}
.modal {
    z-index: 1115 !important;
}
.modal-content {
    border-radius: var(--p360-radius-lg);
    border: none;
    box-shadow: 0 20px 60px rgba(14,30,51,0.2);
}
.modal-header {
    background: var(--p360-primary);
    color: #fff;
    border-radius: var(--p360-radius-lg) var(--p360-radius-lg) 0 0;
    padding: 16px 20px;
    border-bottom: none;
}
.modal-header .modal-title { font-size: 15px; font-weight: 700; color: #fff; }
.modal-header .close {
    color: #fff;
    opacity: 0.8;
    font-size: 20px;
    text-shadow: none;
    padding: 0;
    margin: 0;
}
.modal-header .close:hover { opacity: 1; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--p360-border);
    border-radius: 0 0 var(--p360-radius-lg) var(--p360-radius-lg);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-primary { color: var(--p360-primary) !important; }
.text-accent  { color: var(--p360-accent) !important; }
.text-gold    { color: var(--p360-gold) !important; }
.text-muted   { color: var(--p360-text-muted) !important; }

.bg-primary-soft { background: var(--p360-accent-light) !important; }
.bg-p360-dark    { background: var(--p360-primary-dark) !important; }

.shadow-p360  { box-shadow: var(--p360-shadow) !important; }

.divider-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--p360-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 12px 0;
}
.divider-label::before, .divider-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--p360-border);
}

/* Select2 overrides */
.select2-container--default .select2-selection--single {
    border: 1.5px solid var(--p360-border);
    border-radius: var(--p360-radius-sm);
    height: 36px;
    line-height: 34px;
}
.select2-container--default .select2-selection--single:focus-within,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--p360-accent);
    box-shadow: 0 0 0 3px rgba(74,159,213,0.12);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    #p360-sidebar {
        transform: translateX(-100%);
        width: var(--p360-sidebar-width);
    }
    #p360-sidebar.mobile-open { transform: translateX(0); }
    #p360-topbar { left: 0 !important; }
    #p360-main { margin-left: 0 !important; width: 100% !important; }
    .sidebar-mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(14,30,51,0.4);
        z-index: 1045;
        display: none;
    }
    .sidebar-mobile-overlay.active { display: block; }
}

@media (max-width: 575.98px) {
    .p360-page-content { padding: 16px; }
    .topbar-site-links { display: none; }
    .topbar-user-btn .user-name { display: none; }
    #p360-topbar { padding: 0 14px; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.animate-slide-in { animation: slideInDown 0.3s ease forwards; }
.animate-fade-in  { animation: fadeIn 0.3s ease forwards; }

/* Smooth collapse for Bootstrap collapse elements */
.collapse { transition: height 0.3s ease !important; }
