:root {
  /* Colors - Light Mode */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --secondary: #0F172A;
  --accent: #14B8A6;
  --accent-hover: #0D9488;
  --bg-main: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --border-color: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-blur: blur(12px);
}

[data-theme='dark'] {
  --bg-main: #0D1117;
  --bg-card: #161B22;
  --text-primary: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border-color: #21262D;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection { background: var(--primary); color: #fff; }

.app-wrapper { display: flex; min-height: 100vh; width: 100%; overflow: hidden;}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: var(--bg-sidebar);
  z-index: 1000;
  transition: var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}
.brand-logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-name {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
}
.sidebar.collapsed .brand-name { display: none; }

.sidebar-nav { padding: 1rem 0; }
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-section-title {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
}
.sidebar.collapsed .nav-section-title { display: none; }

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-link:hover, .sidebar-link.active {
    color: var(--primary);
    background: var(--primary-light);
}
.sidebar-link.active {
    border-left-color: var(--primary);
}
.nav-icon {
    font-size: 1.2rem;
    margin-right: 1rem;
    width: 20px;
    text-align: center;
}
.sidebar.collapsed .sidebar-link { padding: 1rem; justify-content: center; }
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .nav-icon { margin-right: 0; font-size: 1.4rem; }

/* Main content area */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding-top: var(--topbar-height);
  background: var(--bg-main);
  transition: var(--transition);
  width: calc(100% - var(--sidebar-width));
}
.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
  width: calc(100% - var(--sidebar-collapsed));
}

/* Top navbar */
.topbar {
  height: var(--topbar-height);
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  z-index: 999;
  transition: var(--transition);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.sidebar.collapsed ~ .topbar { left: var(--sidebar-collapsed); }

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.25rem;
}

.theme-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.notification-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    position: relative;
    padding: 0;
}
.notification-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    padding: 0.2rem 0.4rem;
    font-size: 0.6rem;
}

.user-avatar-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}
.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    overflow: hidden;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem;}

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
}
.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: var(--bg-main); color: var(--primary); }

/* Login Page */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg-main);
    position: relative; overflow: hidden;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem; width: 100%; max-width: 420px; z-index: 10; position: relative;
    box-shadow: var(--shadow-lg);
}
.login-bg-orb {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.3;
    animation: float 6s ease-in-out infinite;
}
.login-bg-orb:nth-child(1) { width: 400px; height: 400px; background: var(--primary); top: -100px; left: -100px; }
.login-bg-orb:nth-child(2) { width: 300px; height: 300px; background: var(--accent); bottom: -50px; right: -50px; animation-delay: 3s; }
@keyframes float { 0%,100% { transform: translateY(0px); } 50% { transform: translateY(-20px); } }

/* Form Controls */
.form-control, .form-select {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-card);
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem var(--primary-light);
    color: var(--text-primary);
}
.form-label { font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; font-size: 0.9rem;}
.input-group-text { background-color: var(--bg-main); border-color: var(--border-color); color: var(--text-secondary); }
.login-card .form-control {
    background: var(--bg-main); border: 1px solid var(--border-color); color: var(--text-primary);
}
.login-card .form-control:focus {
    background: var(--bg-card); border-color: var(--primary); box-shadow: 0 0 0 0.25rem var(--primary-light);
}
.login-card .input-group-text {
    background: var(--bg-main); border: 1px solid var(--border-color); color: var(--text-secondary);
    border-right: none;
}
.login-card .form-control { border-left: none; }

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    transition: var(--transition);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Page Content */
.page-content { padding: 1.5rem 2rem; }
.page-header { margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.page-title { font-family: 'Poppins', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0;}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
}
.card-body { padding: 1.5rem; }

/* Badges */
.badge { font-weight: 500; padding: 0.35em 0.65em; border-radius: 4px; }
.badge-status.active { background: rgba(20,184,166,0.15); color: #14B8A6; }
.badge-status.inactive { background: rgba(239,68,68,0.15); color: #EF4444; }
.badge-status.paid { background: rgba(34,197,94,0.15); color: #22C55E; }
.badge-status.unpaid { background: rgba(239,68,68,0.15); color: #EF4444; }
.badge-status.overdue { background: rgba(245,158,11,0.15); color: #F59E0B; }

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; width: 100%; }
  .topbar { left: 0; }
  .sidebar.collapsed ~ .main-content { margin-left: 0; width: 100%; }
  .sidebar.collapsed ~ .topbar { left: 0; }
}
@media (max-width: 768px) {
  .page-content { padding: 1rem; }
  .page-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
}

@media (min-width: 1200px) {
    .col-xl-3-5 {
        flex: 0 0 auto;
        width: 29.166667% !important;
    }
}

/* ── Premium Data Table Styling ────────────────────────────────────────── */
.data-table-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 20px rgba(0,0,0,0.02) !important;
    overflow: hidden;
}
.data-table-card .card-body {
    padding: 0px !important;
}
.data-table-card .table-responsive {
    padding: 0px !important;
    overflow: visible !important;
}
.data-table-card table.dataTable {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    border-collapse: collapse !important;
    border: 1px solid #e2e8f0 !important;
}
.data-table-card table.dataTable thead {
    background-color: #f8fafc;
}
.data-table-card table.dataTable thead th {
    padding: 14px 20px !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    color: #64748b !important;
    border: 1px solid #e2e8f0 !important;
}
.data-table-card table.dataTable tbody td {
    padding: 16px 20px !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 0.84rem !important;
}
.data-table-card table.dataTable.no-footer {
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Custom design for dataTables search & length controls */
.data-table-filter-row {
    padding: 16px 20px;
    background-color: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}
.data-table-filter-row .dataTables_length select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.82rem;
    color: #334155;
    outline: none;
}
.data-table-filter-row .dataTables_filter input {
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 6px 15px 6px 35px;
    font-size: 0.82rem;
    color: #334155;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' class='bi bi-search' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 14px;
    outline: none;
    width: 200px;
    transition: all 0.3s ease;
}
.data-table-filter-row .dataTables_filter input:focus {
    width: 250px;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.data-table-filter-row .dataTables_filter label {
    margin-bottom: 0 !important;
}

/* Custom design for dataTables info & pagination row */
.data-table-footer-row {
    padding: 16px 20px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}
.data-table-footer-row .dataTables_info {
    font-size: 0.8rem;
    color: #64748b;
    padding-top: 0 !important;
}
.data-table-footer-row .dataTables_paginate {
    padding-top: 0 !important;
}
.data-table-footer-row .dataTables_paginate .pagination {
    margin-bottom: 0 !important;
    gap: 4px;
}
.data-table-footer-row .dataTables_paginate .page-link {
    border-radius: 8px !important;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: #64748b;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}
.data-table-footer-row .dataTables_paginate .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}
.data-table-footer-row .dataTables_paginate .page-link:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

/* ── Topbar Search styles ──────────────────────────────────────────────── */
.topbar-search-wrapper {
    position: relative;
}
.topbar-search-input {
    background-color: #f1f5f9;
    border: none;
    border-radius: 20px;
    padding: 6px 15px 6px 35px;
    font-size: 0.82rem;
    width: 250px;
    transition: width 0.3s ease;
    color: #334155;
}
.topbar-search-input:focus {
    width: 300px;
    background-color: #f1f5f9;
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ── Sparkline Metrics Styles ─────────────────────────────────────────── */
.stat-card-modern {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.stat-card-modern:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.sparkline-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
}
.sparkline-path-blue {
    stroke: #2563eb;
    stroke-width: 2;
    fill: none;
}
.sparkline-fill-blue {
    fill: rgba(37, 99, 235, 0.05);
}
.sparkline-path-green {
    stroke: #22c55e;
    stroke-width: 2;
    fill: none;
}
.sparkline-fill-green {
    fill: rgba(34, 197, 94, 0.05);
}
.sparkline-path-red {
    stroke: #ef4444;
    stroke-width: 2;
    fill: none;
}
.sparkline-fill-red {
    fill: rgba(239, 68, 68, 0.05);
}
.sparkline-path-purple {
    stroke: #a855f7;
    stroke-width: 2;
    fill: none;
}
.sparkline-fill-purple {
    fill: rgba(168, 85, 247, 0.05);
}

/* ── Quick Action Grid styles ─────────────────────────────────────────── */
.quick-action-btn {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 12px;
    text-align: center;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 500;
}
.quick-action-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

/* ── Custom badges ────────────────────────────────────────────────────── */
.badge-service-plan {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    font-weight: 600;
    font-size: 0.72rem;
    border-radius: 6px;
    padding: 4px 8px;
}
.badge-status-active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    font-weight: 600;
    font-size: 0.72rem;
    border-radius: 6px;
    padding: 4px 8px;
}

@media (min-width: 1200px) {
    .col-xl-3-5 {
        flex: 0 0 auto;
        width: 29.166667% !important;
    }
}

/* ── Global Search Results Dropdown ───────────────────────────────────── */
.search-results-dropdown {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
.search-result-group-title {
    font-family: 'Poppins', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 8px 16px 4px;
    background-color: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--border-color);
}
.search-result-item {
    display: flex;
    flex-direction: column;
    padding: 10px 16px;
    text-decoration: none !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    transition: background-color 0.2s ease;
}
.search-result-item:hover {
    background-color: rgba(37, 99, 235, 0.06);
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item-title {
    font-weight: 600;
    font-size: 0.84rem;
}
.search-result-item-subtitle {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.search-results-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
