/* =========================================================
   IT Park Subsidy & Recovery Management System — app.css
   Modern Enterprise UI 2026
   ========================================================= */

/* --- Google Fonts --------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- CSS Custom Properties (Design Tokens) ------------- */
:root {
    /* Primary Brand */
    --primary:          #4F46E5;
    --primary-dark:     #3730A3;
    --primary-light:    #EEF2FF;
    --primary-rgb:      79, 70, 229;

    /* Semantic Colors */
    --success:          #10B981;
    --success-light:    #ECFDF5;
    --success-rgb:      16, 185, 129;

    --warning:          #F59E0B;
    --warning-light:    #FFFBEB;
    --warning-rgb:      245, 158, 11;

    --danger:           #EF4444;
    --danger-light:     #FEF2F2;
    --danger-rgb:       239, 68, 68;

    --info:             #06B6D4;
    --info-light:       #ECFEFF;
    --info-rgb:         6, 182, 212;

    --orange:           #F97316;
    --orange-light:     #FFF7ED;
    --orange-rgb:       249, 115, 22;

    /* Sidebar */
    --sidebar-bg:       #0F172A;
    --sidebar-surface:  #1E293B;
    --sidebar-hover:    rgba(79, 70, 229, 0.12);
    --sidebar-active:   #4F46E5;
    --sidebar-text:     #94A3B8;
    --sidebar-text-dim: #64748B;
    --sidebar-width:    272px;

    /* Surface & Background */
    --bg:               #F1F5F9;
    --surface:          #FFFFFF;
    --surface-2:        #F8FAFC;

    /* Text */
    --text:             #0F172A;
    --text-secondary:   #475569;
    --muted:            #64748B;

    /* Border */
    --border:           #E2E8F0;
    --border-strong:    #CBD5E1;

    /* Shadow */
    --shadow-xs:        0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm:        0 1px 3px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md:        0 4px 16px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-lg:        0 10px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
    --shadow-primary:   0 4px 20px rgba(79, 70, 229, 0.25);

    /* Radius */
    --radius-sm:        0.375rem;
    --radius:           0.625rem;
    --radius-lg:        0.875rem;
    --radius-xl:        1.25rem;

    /* Transition */
    --transition:       0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow:  0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-shell {
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- SVG Icon System ----------------------------------- */
.app-icon {
    width: 1.1rem;
    height: 1.1rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.btn .app-icon {
    width: 1rem;
    height: 1rem;
}

.stat-icon .app-icon {
    width: 1.6rem;
    height: 1.6rem;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
    overflow: hidden;
}

/* Sidebar inner scroll */
.app-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.app-sidebar-inner::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar-inner::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.1);
    border-radius: 4px;
}

/* Logo Area */
.app-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem 1rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.06);
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.app-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.5);
}

.app-logo-icon .app-icon {
    width: 1.2rem;
    height: 1.2rem;
    stroke: #fff;
}

.app-logo-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

/* Nav Labels */
.app-nav {
    flex: 1;
    padding: 0.25rem 0.75rem;
}

.app-nav-label {
    margin: 1rem 0.25rem 0.35rem;
    color: var(--sidebar-text-dim);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Nav Links */
.app-nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    margin-bottom: 0.15rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    text-align: left;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.app-nav-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.04);
    opacity: 0;
    transition: opacity var(--transition);
}

.app-nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.07);
}

.app-nav-link:hover::before {
    opacity: 1;
}

.app-nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, #6366F1 100%);
    box-shadow: 0 4px 12px rgba(79,70,229,.35);
    font-weight: 600;
}

.app-nav-link.active .app-nav-icon {
    background: rgba(255,255,255,.2);
}

/* Collapsed state for sub-menu toggles */
.app-nav-link.collapsed {
    color: var(--sidebar-text);
    background: transparent;
}

/* Nav Icons */
.app-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,.07);
    transition: background var(--transition);
}

.app-nav-icon .app-icon {
    width: 0.95rem;
    height: 0.95rem;
}

.app-nav-link:hover .app-nav-icon {
    background: rgba(255,255,255,.12);
}

/* Sub-menu */
.app-nav-submenu {
    padding: 0.15rem 0 0.15rem 0.875rem;
    margin-left: 0.875rem;
    border-left: 1px solid rgba(255,255,255,.08);
}

.app-nav-submenu .app-nav-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
}

/* Reset button for nav */
.btn-reset {
    border: 0;
    background: transparent;
    cursor: pointer;
}

/* User Area at bottom */
.app-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    margin: 0.5rem 0.75rem 0;
    border-radius: var(--radius);
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.app-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.app-user-name,
.app-user-role {
    margin: 0;
    line-height: 1.3;
}

.app-user-name {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user-role {
    color: var(--sidebar-text-dim);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.min-w-0 {
    min-width: 0;
}

/* =========================================================
   SIDEBAR BACKDROP (Mobile)
   ========================================================= */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(10, 15, 30, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* =========================================================
   MAIN CONTENT AREA
   ========================================================= */
.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-slow);
}

/* =========================================================
   TOPBAR
   ========================================================= */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-xs);
    flex-shrink: 0;
}

/* Mobile toggle */
#mobile-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    transition: all var(--transition);
}

#mobile-toggle:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Breadcrumb */
.app-breadcrumb {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.app-breadcrumb span {
    margin: 0 0.4rem;
    color: var(--border-strong);
}

.app-breadcrumb strong {
    color: var(--text);
    font-weight: 600;
}

/* Topbar right side (notification area) */
.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-action {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.topbar-action:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */
.app-content {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 1.5rem 1.75rem;
    flex: 1;
}

/* =========================================================
   PAGE HEADER
   ========================================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header.compact {
    margin-top: 1.25rem;
}

.page-header h1,
.page-header h2 {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-header h1 {
    font-size: 1.4rem;
}

.page-header h2 {
    font-size: 1.15rem;
}

.page-header p {
    margin: 0.2rem 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 400;
}

/* =========================================================
   CARDS
   ========================================================= */
.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.app-card:hover {
    box-shadow: var(--shadow-md);
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

.card-header {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 0.875rem 1.25rem !important;
    font-weight: 600;
}

.card-footer {
    background: var(--surface-2) !important;
    border-top: 1px solid var(--border) !important;
    padding: 0.875rem 1.25rem !important;
}

.card-body {
    padding: 1.25rem;
}

/* =========================================================
   STAT CARDS
   ========================================================= */
.stat-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

/* =========================================================
   SUMMARY WIDGET CARDS (Outstanding Balance, Security Deposit, etc.)
   ========================================================= */
.summary-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    container-type: inline-size;
    container-name: summarycard;
}

.summary-card .card-body {
    padding: 0.75rem 0.75rem !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

@media (min-width: 1400px) {
    .summary-card .card-body {
        padding: 0.875rem 1rem !important;
    }
}

.summary-card h6 {
    font-size: 0.7rem !important;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    margin-bottom: 0.35rem !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-amount {
    white-space: nowrap !important;
    overflow: visible !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    font-size: clamp(0.72rem, 1.15vw, 1.25rem) !important;
    letter-spacing: -0.025em !important;
    display: block;
    width: 100%;
}

@supports (container-type: inline-size) {
    .summary-amount {
        font-size: clamp(0.72rem, 7.8cqw, 1.25rem) !important;
    }
}



.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.04;
    transform: translate(20px, -20px);
    transition: transform var(--transition-slow);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card p {
    margin: 0 0 0.25rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stat-card h3 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    flex-shrink: 0;
}

/* Stat color variants */
.stat-primary {
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary-light) 0%, rgba(99,102,241,.08) 100%);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.15);
}

.stat-success {
    color: var(--success);
    background: linear-gradient(135deg, var(--success-light) 0%, rgba(16,185,129,.08) 100%);
    box-shadow: 0 2px 8px rgba(var(--success-rgb), 0.15);
}

.stat-warning {
    color: var(--warning);
    background: linear-gradient(135deg, var(--warning-light) 0%, rgba(245,158,11,.08) 100%);
    box-shadow: 0 2px 8px rgba(var(--warning-rgb), 0.15);
}

.stat-danger {
    color: var(--danger);
    background: linear-gradient(135deg, var(--danger-light) 0%, rgba(239,68,68,.08) 100%);
    box-shadow: 0 2px 8px rgba(var(--danger-rgb), 0.15);
}

.stat-info {
    color: var(--info);
    background: linear-gradient(135deg, var(--info-light) 0%, rgba(6,182,212,.08) 100%);
    box-shadow: 0 2px 8px rgba(var(--info-rgb), 0.15);
}

/* =========================================================
   TABLES
   ========================================================= */
.table {
    --bs-table-hover-bg: rgba(79, 70, 229, 0.03);
    --bs-table-striped-bg: #F8FAFC;
    margin-bottom: 0;
}

table th,
.table th,
.table thead th,
table.dataTable th,
table.dataTable thead th {
    padding: 0.7rem 1rem;
    color: var(--muted);
    background: var(--surface-2);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap !important;
}

.table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.83rem;
    color: var(--text-secondary);
    border-color: var(--border);
    vertical-align: middle;
    transition: background var(--transition);
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover td {
    background: rgba(var(--primary-rgb), 0.025);
}

.table-responsive {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    gap: 0.4rem;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
}

/* Primary Button */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, #6366F1 100%);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    border-color: transparent;
    box-shadow: var(--shadow-primary);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Outline Secondary */
.btn-outline-secondary {
    --bs-btn-color: var(--muted);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: var(--border-strong);
    font-weight: 600;
}

/* Outline Primary */
.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: rgba(var(--primary-rgb), 0.4);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
}

/* Danger */
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(var(--danger-rgb), 0.3);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(var(--danger-rgb), 0.35);
    transform: translateY(-1px);
}

/* Icon Button */
.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* =========================================================
   FORM CONTROLS
   ========================================================= */
.form-control,
.form-select {
    font-size: 0.83rem;
    font-weight: 400;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}

.form-select {
    padding-right: 2.5rem;
    text-overflow: ellipsis;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    outline: none;
    background: var(--surface);
    color: var(--text);
}

.form-control::placeholder {
    color: #B0BCCF;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--muted);
}

/* =========================================================
   BADGES
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.28rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.015em;
    border-radius: 50rem;
    text-transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Paid / Success Status & Category Badges */
.badge.text-bg-success,
.badge.bg-success,
.badge-paid,
.badge-status-paid,
.bill-status-paid,
.ledger-badge-paid,
.badge.bg-success-subtle,
.badge.bg-success-subtle.text-success-emphasis {
    background-color: #0F8A4B !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Pending / Warning Status & Electricity Category Badges */
.badge.text-bg-warning,
.badge.bg-warning,
.badge.bg-warning.text-dark,
.badge-pending,
.badge-status-pending,
.bill-status-pending,
.ledger-badge-pending,
.badge.bg-warning-subtle,
.badge.bg-warning-subtle.text-warning-emphasis {
    background-color: #F97316 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Info / Rent Category Badges */
.badge.text-bg-info,
.badge.bg-info,
.badge.bg-info-subtle,
.badge.bg-info-subtle.text-info-emphasis {
    background-color: #0284C7 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Primary / Broadband Category Badges */
.badge.text-bg-primary,
.badge.bg-primary,
.badge.bg-primary-subtle,
.badge.bg-primary-subtle.text-primary-emphasis {
    background-color: #4F46E5 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Danger / Security Fee / Overdue Category Badges */
.badge.text-bg-danger,
.badge.bg-danger,
.badge.bg-danger-subtle,
.badge.bg-danger-subtle.text-danger-emphasis {
    background-color: #E11D48 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Secondary / Neutral / Checked Out / Adjustment Badges */
.badge.bg-secondary,
.badge.text-bg-secondary,
.badge.bg-secondary-subtle,
.badge.bg-secondary-subtle.text-secondary-emphasis {
    background-color: #5B6770 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Dark / Opening Balance Badges */
.badge.bg-dark,
.badge.text-bg-dark,
.badge.bg-dark-subtle,
.badge.bg-dark-subtle.text-dark-emphasis {
    background-color: #1E293B !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Light / Generic Fallback Badges */
.badge.bg-light,
.badge.bg-light.text-dark {
    background-color: #475569 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* =========================================================
   ROLE BADGES SYSTEM
   ========================================================= */
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.25;
    border-radius: 50rem;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: 0.015em;
    text-transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Admin: Red badge with white text */
.role-badge-admin,
.role-badge.role-badge-admin,
.role-badge.admin {
    background-color: #E11D48 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Recovery Officer: Yellow/amber badge with black text */
.role-badge-officer,
.role-badge-recovery-officer,
.role-badge.role-badge-officer,
.role-badge.officer {
    background-color: #FFB800 !important;
    color: #000000 !important;
    border: none !important;
}

/* Supervisor: Blue badge with white text */
.role-badge-supervisor,
.role-badge.role-badge-supervisor,
.role-badge.supervisor {
    background-color: #0066FF !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Superadmin / Super Admin fallback */
.role-badge-super,
.role-badge-superadmin,
.role-badge.superadmin {
    background-color: #881337 !important;
    color: #FFFFFF !important;
    border: none !important;
}

.role-badge-default {
    background-color: #64748B !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* =========================================================
   STATUS BADGES SYSTEM (Active & Checked Out)
   ========================================================= */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 50rem;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: 0.015em;
    text-transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Active: Green badge with white text */
.status-badge-active,
.status-badge.active,
.status-active {
    background-color: #0F8A4B !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* Checked Out: Gray badge with white text */
.status-badge-checkout,
.status-badge-checked-out,
.status-badge.checked-out,
.status-checked-out {
    background-color: #5B6770 !important;
    color: #FFFFFF !important;
    border: none !important;
}

/* =========================================================
   POLICY BADGES SYSTEM
   ========================================================= */
.policy-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 50rem;
    background-color: #5B6770 !important;
    color: #FFFFFF !important;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    letter-spacing: 0.015em;
    text-transform: none;
    border: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}




/* =========================================================
   ALERTS
   ========================================================= */
.alert {
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 0.83rem;
    padding: 0.875rem 1.125rem;
}

.alert-primary {
    background: var(--primary-light);
    border-color: rgba(var(--primary-rgb), 0.2);
    color: var(--primary-dark);
}

.alert-success {
    background: var(--success-light);
    border-color: rgba(var(--success-rgb), 0.2);
    color: #065F46;
}

.alert-warning {
    background: var(--warning-light);
    border-color: rgba(var(--warning-rgb), 0.2);
    color: #92400E;
}

.alert-danger {
    background: var(--danger-light);
    border-color: rgba(var(--danger-rgb), 0.2);
    color: #991B1B;
}

.alert-info {
    background: var(--info-light);
    border-color: rgba(var(--info-rgb), 0.2);
    color: #0E7490;
}

/* =========================================================
   MODALS
   ========================================================= */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border) !important;
    padding: 1.1rem 1.5rem !important;
}

.modal-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 1.5rem !important;
    background: var(--surface);
}

.modal-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border) !important;
    padding: 0.875rem 1.5rem !important;
    gap: 0.5rem;
}

.modal-backdrop {
    background-color: #0F172A;
}

.modal-backdrop.show {
    opacity: 0.6;
}

/* =========================================================
   DATATABLES OVERRIDES
   ========================================================= */
.dataTables_wrapper {
    font-size: 0.83rem;
}

.dataTables_filter {
    display: none !important;
}

.dataTables_length label {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dataTables_length select {
    display: inline-block;
    width: auto !important;
    padding: 0.35rem 1.75rem 0.35rem 0.625rem;
    font-size: 0.78rem;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.dataTables_length select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    outline: none;
}

.dataTables_info {
    font-size: 0.77rem;
    color: var(--muted);
    font-weight: 500;
    padding-top: 0.25rem;
}

/* Pagination */
.dataTables_paginate .paginate_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem !important;
    margin: 0 0.1rem !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text-secondary) !important;
    transition: all var(--transition) !important;
    cursor: pointer !important;
}

.dataTables_paginate .paginate_button:hover {
    background: var(--primary-light) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    box-shadow: none !important;
}

.dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3) !important;
}

.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    background: var(--surface-2) !important;
    color: var(--muted) !important;
}

/* DataTable DOM wrapper rows */
.dataTables_wrapper .row {
    align-items: center;
}

/* Processing overlay */
.dataTables_wrapper .dataTables_processing {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    box-shadow: none !important;
}

.dataTables_wrapper .dataTables_processing > div:last-child {
    display: none !important;
}

/* =========================================================
   SEARCH FIELD
   ========================================================= */
.search-field {
    width: min(100%, 300px);
    display: flex !important;
    visibility: visible !important;
}

/* =========================================================
   COMPANY AVATAR
   ========================================================= */
.company-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* =========================================================
   CONTACT CODE / INFO PILLS
   ========================================================= */
.contact-code {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

/* =========================================================
   POLICY DOT INDICATOR
   ========================================================= */
.policy-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-primary  { background: var(--primary); }
.dot-success  { background: var(--success); }
.dot-warning  { background: var(--warning); }
.dot-danger   { background: var(--danger); }

/* =========================================================
   INFO LABELS (ledger, bill detail)
   ========================================================= */
.info-label {
    margin-bottom: 0.3rem;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.info-value {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

/* =========================================================
   LOADER / SPINNER
   ========================================================= */
.loader {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2.5px solid rgba(var(--primary-rgb), 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */
.toast-container {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.625rem;
    pointer-events: none;
    max-width: calc(100vw - 3rem);
}

.toast-message {
    position: relative;
    pointer-events: auto;
    width: 340px;
    max-width: 100%;
    padding: 0.875rem 1.25rem 0.875rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    font-size: 0.83rem;
    color: var(--text);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    word-break: break-word;
    border-left: 4px solid var(--success);
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

.toast-message.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-message.danger,
.toast-message.error {
    border-left-color: var(--danger);
}

.toast-message.warning {
    border-left-color: var(--warning);
}

/* =========================================================
   HELP PANEL
   ========================================================= */
.help-panel {
    padding: 1.25rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.help-panel p {
    margin: 0 0 1rem;
    color: var(--muted);
    text-align: center;
    font-size: 0.83rem;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 40%, #312E81 100%);
    position: relative;
    overflow: hidden;
}

/* Decorative orbs */
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.login-page::before {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99,102,241,.3) 0%, transparent 70%);
    top: -150px;
    right: -100px;
}

.login-page::after {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16,185,129,.2) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    background: rgba(255,255,255,.97);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
    box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.4);
}

.login-mark .app-icon {
    width: 2rem;
    height: 2rem;
    stroke: #fff;
}

.login-brand h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    text-align: center;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: var(--muted);
    text-align: center;
    font-size: 0.83rem;
    margin-bottom: 1.75rem;
}

.login-footer {
    margin: 1.5rem 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

/* =========================================================
   CUSTOM CHECKBOX DROPDOWN
   ========================================================= */
.dropdown-checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    user-select: none;
    transition: background var(--transition);
    gap: 0.5rem;
}

.dropdown-checkbox-item:hover {
    background: var(--surface-2);
}

.dropdown-checkbox-item input[type="checkbox"] {
    cursor: pointer;
    width: 1rem;
    height: 1rem;
    margin-top: 0;
    accent-color: var(--primary);
}

.dropdown-checkbox-item label {
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 0;
}

/* =========================================================
   DROPDOWN MENUS
   ========================================================= */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.375rem;
    font-size: 0.82rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}

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

/* =========================================================
   COLLAPSE ARROWS
   ========================================================= */
.app-nav-link[aria-expanded="true"] .collapse-chevron {
    transform: rotate(180deg);
}

.collapse-chevron {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform var(--transition);
    opacity: 0.6;
}

/* =========================================================
   UTILITY CLASSES
   ========================================================= */
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.fw-800  { font-weight: 800; }
.fs-7    { font-size: 0.75rem; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted   { color: var(--muted) !important; }
.bg-primary   { background: var(--primary) !important; }

/* =========================================================
   RESPONSIVE — TABLET / MOBILE
   ========================================================= */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .app-sidebar.mobile-active {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding: 0 1.25rem;
    }

    .app-content {
        padding: 1.25rem;
    }
}

@media (max-width: 767.98px) {
    .app-content {
        padding: 1rem;
    }

    .app-topbar {
        padding: 0 1rem;
        height: 56px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-header > .btn,
    .page-header > .d-flex {
        width: 100%;
    }

    .page-header > .d-flex {
        flex-direction: column;
    }

    .stat-card h3 {
        font-size: 1.4rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 575.98px) {
    .app-content {
        padding: 0.875rem;
    }

    .app-breadcrumb {
        font-size: 0.75rem;
    }

    .modal-body {
        padding: 1.25rem !important;
    }
}

/* =========================================================
   TABLE SEARCH — Shared component for all DataTable headers
   ========================================================= */
.table-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 260px;
}

.table-search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    display: flex;
    align-items: center;
    color: var(--muted);
    z-index: 2;
}

.table-search-icon svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.table-search .form-control {
    padding-left: 2.1rem;
    height: 36px;
    font-size: 0.82rem;
    border-color: var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.table-search .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    outline: none;
}

.table-search .form-control::placeholder {
    color: var(--muted);
    font-size: 0.8rem;
}

/* --- Table Vertical Alignment --- */
.table td,
table.dataTable td,
table td {
    vertical-align: top !important;
}

