/* =====================================================
   PharmaCare HMS — Design System
   Modern SaaS Dashboard Aesthetic
   ===================================================== */

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

/* ─── CSS Custom Properties (Light Theme) ───────── */
:root {
    /* Primary Palette (Modern Indigo SaaS) */
    --primary: #4F46E5;
    --primary-dark: #3730A3;
    --primary-light: #818CF8;
    --primary-bg: #EEF2FF;
    --primary-border: #E0E7FF;

    /* Semantic Colors (Premium Refined) */
    --success: #10B981;
    --success-bg: #ECFDF5;
    --success-border: #D1FAE5;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --warning-border: #FEF3C7;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --danger-border: #FEE2E2;
    --info: #3B82F6;
    --info-bg: #EFF6FF;

    /* Neutrals - Advanced Sidebar */
    --sidebar-bg: #FFFFFF;
    --sidebar-hover: #F8FAFC;
    --sidebar-active: #F1F5F9;
    --sidebar-text: #475569;
    --sidebar-text-active: #1E293B;
    --sidebar-border: #F1F5F9;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;

    /* Background & Surface */
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-hover: #F1F5F9;
    --surface-border: #E2E8F0;


    /* Text */
    --text: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-inverse: #FFFFFF;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Border Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Spacing */
    --top-bar-height: 72px;
    --content-padding: 32px;
    --card-padding: 28px;

    /* Font */
    --font: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─── Dark Theme ────────────────────────────────── */
[data-theme="dark"] {
    /* Primary Brand Dark */
    --primary: #818CF8;
    --primary-dark: #A5B4FC;
    --primary-light: #6366F1;
    --primary-bg: rgba(79, 70, 229, 0.15);
    --primary-border: #4338CA;

    /* Semantic Colors (Dark Optimised) */
    --success: #34D399;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-border: #065F46;
    --warning: #FBBF24;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-border: #92400E;
    --danger: #F87171;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-border: #991B1B;
    --info: #60A5FA;
    --info-bg: rgba(59, 130, 246, 0.15);

    --bg: #0F172A;
    --surface: #1E293B;
    --surface-hover: #1E293B;
    --surface-border: rgba(255, 255, 255, 0.05);
    
    --text: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    
    /* Sidebar */
    --sidebar-bg: #020617;
    --sidebar-hover: #0F172A;
    --sidebar-active: #1E293B;
    --sidebar-text: #94A3B8;
    --sidebar-text-active: #FFFFFF;
    --sidebar-border: rgba(255, 255, 255, 0.03);
}


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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    display: block;
}

/* ─── App Layout ────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition-slow);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.content-area {
    flex: 1;
    padding: var(--content-padding);
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
}


/* ─── Sidebar ───────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: var(--transition-slow);
    z-index: 1000;
    overflow: hidden;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 64px;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--surface);
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-text-active);
    white-space: nowrap;
    opacity: 1;
    transition: var(--transition);
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--sidebar-text);
    outline: none;
    padding: 4px;
    margin-left: auto;
}

@media (max-width: 1023px) {
    .sidebar-close-btn {
        display: block !important;
    }
}

.sidebar-collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

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

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

/* ─── Sidebar Navigation Menu (ul/li) ──────────── */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu > .nav-section {
    margin-top: 4px;
}

.nav-menu > .nav-section:first-child {
    margin-top: 0;
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 10px 16px 4px;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: var(--transition);
}

.nav-section-header:hover {
    color: var(--sidebar-text-active);
}

.nav-section-title {
    flex: 1;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    opacity: 0.4;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

.nav-section-header:hover .nav-section-title {
    opacity: 0.6;
}

.nav-arrow {
    font-size: 10px;
    transition: transform 0.25s ease;
    opacity: 0.5;
    flex-shrink: 0;
    margin-right: 8px;
}

.nav-section-header[aria-expanded="true"] .nav-arrow {
    transform: rotate(180deg);
}

.nav-arrow:hover {
    opacity: 0.9;
}

/* Submenu (the ul inside each nav-section) */
.nav-submenu {
    list-style: none;
    padding: 2px 0 6px;
    margin: 0;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
    opacity: 1;
}

.nav-submenu.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.nav-submenu li {
    list-style: none;
}

.nav-submenu .nav-item {
    padding-left: 28px;
}

/* Empty submenu fallback message */
.nav-empty-msg {
    padding: 8px 16px 8px 28px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.6;
    white-space: nowrap;
}

/* Badge inside nav items */
.nav-badge {
    margin-left: auto;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

/* Collapsed sidebar state */
.sidebar-collapsed .nav-section-header {
    justify-content: center;
    padding: 10px 8px 4px;
}

.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .nav-arrow,
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .nav-submenu {
    display: none !important;
}

.sidebar-collapsed .nav-section-header .nav-section-title {
    opacity: 0;
    width: 0;
}

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

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 700;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.nav-item .nav-text {
    opacity: 1;
    transition: var(--transition);
}

.sidebar-collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-user:hover {
    background: var(--sidebar-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    overflow: hidden;
    white-space: nowrap;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.user-role {
    font-size: 11px;
    color: var(--sidebar-text);
    text-transform: capitalize;
}

.sidebar-collapsed .user-info {
    opacity: 0;
    width: 0;
}

/* ─── Top Bar ───────────────────────────────────── */
.top-bar {
    height: var(--top-bar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.85);
}

[data-theme="dark"] .top-bar {
    background: rgba(22, 25, 34, 0.85);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    list-style: none;
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    color: var(--text-muted);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 16px;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.top-bar-user:hover {
    background: var(--surface-hover);
}

/* ─── Cards ─────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
    margin: 1.25rem;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--surface-border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-body {
    padding: var(--card-padding);
}


.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--surface-border);
    background: var(--surface-hover);
}

/* ─── KPI / Stat Cards ──────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    opacity: 0;
    transition: var(--transition);
}

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

.stat-card:hover::after {
    opacity: 1;
}

.stat-card.primary::after { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card.success::after { background: linear-gradient(90deg, var(--success), #34D399); }
.stat-card.warning::after { background: linear-gradient(90deg, var(--warning), #FCD34D); }
.stat-card.danger::after { background: linear-gradient(90deg, var(--danger), #F87171); }

.stat-info { flex: 1; }

.stat-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.stat-change {
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

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

.stat-icon.primary { background: var(--primary-bg); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }
.stat-icon.indigo { background: var(--primary-bg); color: var(--primary); }

/* ─── Tables ────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
    margin: 1.25rem;
}


table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead {
    background: var(--surface-hover);
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--surface-border);
}

tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid var(--surface-border);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--surface-hover);
}

tbody td {
    padding: 14px 16px;
    color: var(--text);
    vertical-align: middle;
}

/* ─── Badges ────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); border: 1px solid var(--primary-border); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-secondary { background: var(--surface-hover); color: var(--text-secondary); border: 1px solid var(--surface-border); }

/* ─── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1.5px solid transparent;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
    user-select: none;
    outline: none;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4338CA 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #6366F1 0%, var(--primary) 100%);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -2px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
    color: #FFFFFF;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #34D399 0%, var(--success) 100%);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
    transform: translateY(-2px);
    color: #FFFFFF;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #D97706 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.2);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #FBBF24 0%, var(--warning) 100%);
    box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.3);
    transform: translateY(-2px);
    color: #FFFFFF;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    color: #fff;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--surface-border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-action {
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    font-size: 13px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: unset !important;
    min-height: unset !important;
}

/* ─── Forms ─────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #64748B;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13.5px;
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-control::selection {
    background: var(--primary-bg);
    color: var(--primary-dark);
}

select.form-control:focus,
select.form-control:active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* Validations */
.border-danger {
    border-color: var(--danger) !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    border: 1.5px solid #64748B;
    border-radius: var(--radius);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--surface-border);
}

/* Checkbox / Toggle */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ─── Alerts / Flash Messages ───────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
    border: 1px solid transparent;
    position: relative;
    border-left: 4px solid transparent;
}

/* Alert Variants */
.alert-primary {
    background: var(--primary-bg);
    color: #3730A3;
    border-color: var(--primary-border);
    border-left-color: var(--primary);
}

.alert-secondary {
    background: #F1F5F9;
    color: #334155;
    border-color: #E2E8F0;
    border-left-color: #64748B;
}

.alert-success {
    background: var(--success-bg);
    color: #15803D;
    border-color: var(--success-border);
    border-left-color: var(--success);
}

.alert-danger,
.alert-error {
    background: var(--danger-bg);
    color: #B91C1C;
    border-color: var(--danger-border);
    border-left-color: var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    color: #A16207;
    border-color: var(--warning-border);
    border-left-color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: #1D4ED8;
    border-color: rgba(59, 130, 246, 0.2);
    border-left-color: var(--info);
}

.alert-light {
    background: #F8FAFC;
    color: #475569;
    border-color: #E2E8F0;
    border-left-color: #CBD5E1;
}

.alert-dark {
    background: #1E293B;
    color: #F1F5F9;
    border-color: #334155;
    border-left-color: #0F172A;
}

/* Dark theme alert overrides */
[data-theme="dark"] .alert-primary {
    background: rgba(79, 70, 229, 0.2);
    color: #A5B4FC;
    border-color: rgba(79, 70, 229, 0.3);
}

[data-theme="dark"] .alert-secondary {
    background: rgba(71, 85, 105, 0.2);
    color: #CBD5E1;
    border-color: rgba(71, 85, 105, 0.3);
}

[data-theme="dark"] .alert-light {
    background: rgba(248, 250, 252, 0.08);
    color: #E2E8F0;
    border-color: rgba(203, 213, 225, 0.2);
}

[data-theme="dark"] .alert-dark {
    background: #0F172A;
    color: #F8FAFC;
    border-color: #1E293B;
}

.alert .alert-icon {
    flex-shrink: 0;
    color: currentColor;
    opacity: 0.8;
}

.alert .alert-close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.6;
    font-size: 16px;
    background: none;
    border: none;
    color: inherit;
}

.alert .alert-close:hover {
    opacity: 1;
}

/* ─── Search & Filters ──────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

.search-input-wrapper .form-control {
    padding-left: 42px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Pagination ────────────────────────────────── */
.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 4px;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
    background: var(--surface);
    transition: var(--transition);
}

.page-link:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ─── DataTables Modern Pagination Override ─────── */
.dataTables_wrapper .dataTables_paginate {
    float: none !important;
    text-align: center !important;
    padding-top: 1.5rem !important;
    padding-bottom: 0.5rem !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 14px !important;
    margin: 0 3px !important;
    border-radius: 50px !important;
    font-family: var(--font) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
    background: var(--surface) !important;
    border: 1.5px solid var(--surface-border) !important;
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-decoration: none !important;
    line-height: 1 !important;
    box-shadow: var(--shadow-sm) !important;
    outline: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-bg) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, var(--primary) 0%, #4338CA 100%) !important;
    border-color: var(--primary) !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255,255,255,0.15) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(135deg, #6366F1 0%, var(--primary) 100%) !important;
    color: #FFFFFF !important;
    transform: translateY(-1px) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next {
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
}

/* DataTables info text */
.dataTables_wrapper .dataTables_info {
    padding-top: 0.5rem !important;
    font-size: 12.5px !important;
    color: var(--text-muted) !important;
    font-weight: 500 !important;
}

/* DataTables length menu */
.dataTables_wrapper .dataTables_length {
    padding-bottom: 0.75rem !important;
}

.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--surface-border) !important;
    border-radius: 50px !important;
    padding: 6px 28px 6px 14px !important;
    font-family: var(--font) !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    background: var(--surface) !important;
    margin: 0 6px !important;
    cursor: pointer !important;
    outline: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    transition: var(--transition) !important;
}

.dataTables_wrapper .dataTables_length select:hover,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--primary) !important;
}

/* DataTables filter/search input */
.dataTables_wrapper .dataTables_filter input {
    border: 1.5px solid var(--surface-border) !important;
    border-radius: 50px !important;
    padding: 8px 16px !important;
    font-family: var(--font) !important;
    font-size: 13px !important;
    color: var(--text) !important;
    background: var(--surface) !important;
    margin-left: 8px !important;
    outline: none !important;
    transition: var(--transition) !important;
    min-width: 220px !important;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-bg) !important;
}

.dataTables_wrapper .dataTables_filter label {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
}

/* Responsive DataTables pagination */
@media (max-width: 640px) {
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-width: 32px !important;
        height: 32px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
        margin: 0 2px !important;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        min-width: 150px !important;
    }
}

/* ─── DataTables Loading Progress Bar ──────────── */
.dataTables_wrapper .dt-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 10;
    overflow: hidden;
    border-radius: 3px 3px 0 0;
}

.dataTables_wrapper .dt-progress-bar .dt-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #6366F1, var(--primary));
    background-size: 200% 100%;
    border-radius: 3px;
    animation: dt-progress-shimmer 1.5s infinite linear;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dt-progress-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dataTables_wrapper .dt-progress-bar .dt-progress-fill.indeterminate {
    width: 40% !important;
    animation: dt-progress-indeterminate 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dt-progress-indeterminate {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(150%); }
    100% { transform: translateX(-100%); }
}

/* Pagination Previous/Next SVG icons */
.dataTables_wrapper .dataTables_paginate .paginate_button.previous::before {
    content: '‹';
    font-size: 18px;
    font-weight: 700;
    margin-right: 2px;
    line-height: 1;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.next::after {
    content: '›';
    font-size: 18px;
    font-weight: 700;
    margin-left: 2px;
    line-height: 1;
}

/* ─── Empty State ───────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

/* ─── Charts Container ─────────────────────────── */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* ─── Action Buttons Row ────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-left {
    display: flex;
    flex-direction: column;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
}

.page-header .page-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ─── Info List (Patient Detail) ────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 12px 0;
}

.info-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ─── Tabs ──────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--surface-border);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 20px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    text-decoration: none;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ─── Receipt / Print Styles ────────────────────── */
.receipt {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.receipt-header {
    padding: 32px;
    text-align: center;
    border-bottom: 2px dashed var(--surface-border);
}

.receipt-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

.receipt-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.receipt-body {
    padding: 32px;
}

.receipt-footer {
    padding: 24px 32px;
    border-top: 2px dashed var(--surface-border);
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.receipt-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.receipt-totals {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--surface-border);
}

.receipt-total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.receipt-total-row.grand-total {
    font-size: 18px;
    font-weight: 700;
    padding-top: 12px;
    border-top: 2px solid var(--text);
}

/* ─── Statement (Ledger) ────────────────────────── */
.statement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    color: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.statement-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.debit { color: var(--danger); }
.credit { color: var(--success); }

/* ─── Animations ────────────────────────────────── */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-in {
    animation: fadeIn 0.4s ease forwards;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }

/* ─── Utility Classes ──────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-10 { margin-top: 2.5rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.bg-primary { background: var(--primary) !important; }
.bg-white { background: #FFFFFF !important; }
.text-white { color: #FFFFFF !important; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }

/* Grid & Flexbox Layout Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.row { display: flex; flex-wrap: wrap; margin-right: -15px; margin-left: -15px; }
.row > [class*="col-"] { padding-right: 15px; padding-left: 15px; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.items-center { align-items: center; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.col-span-1 { grid-column: span 1 / span 1; }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }

@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .col-span-1, .col-span-2, .col-span-3, .col-span-4 { grid-column: span 1 / span 1; }
}

/* ─── Login Page (Updated White Theme) ────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image: radial-gradient(at 0% 0%, rgba(79, 110, 247, 0.05) 0, transparent 50%), 
                      radial-gradient(at 50% 0%, rgba(139, 92, 246, 0.05) 0, transparent 50%);
    position: relative;
    overflow: hidden;
}

.auth-card {
    width: 440px;
    display: flex;
    flex-direction: column;
    height: min(680px, calc(100vh - 48px));
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: 48px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-xl);
}

.auth-logo {
    text-align: center;
    margin-bottom: 40px;
}

.auth-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #fff;
    margin-bottom: 20px;
    box-shadow: 0 10px 15px -3px rgba(79, 110, 247, 0.3);
}

.auth-logo h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.auth-card .form-label {
    color: var(--text);
}

.auth-card .form-control {
    background: var(--bg);
    border-color: #64748B;
    color: var(--text);
}

.auth-card .form-control:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.1);
}

.auth-card .form-control::placeholder {
    color: var(--text-muted);
}

.auth-card .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 10px;
}

/* ─── Auth Card Footer ──────────────────────────── */
.auth-card-footer {
    margin-top: auto;   /* pin to the bottom of the card */
    padding-top: 20px;
    border-top: 1px solid var(--surface-border);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.8;
}
.auth-card-footer .auth-footer-line {
    margin: 0;
}
.auth-card-footer .auth-heart {
    color: #ef4444;
}
.auth-card-footer strong {
    color: var(--text-secondary);
    font-weight: 700;
}
@media (max-width: 480px) {
    .auth-card {
        height: auto;            /* let the card size to its content on phones */
        min-height: 0;
        max-height: none;
        overflow-y: visible;
    }
    .auth-card-footer {
        margin-top: 20px;
        font-size: 11px;
    }
}


/* ─── Mobile Overlay ────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1040;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block !important;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--surface-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ─── Reports Specific ──────────────────────────── */
.report-filters {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.report-filters .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.report-summary-item {
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    text-align: center;
}

.report-summary-item .label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.report-summary-item .value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

/* ─── Toast Notifications ───────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    min-width: 300px;
    padding: 14px 18px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-success { background: #16A34A; }
.toast-error { background: #DC2626; }
.toast-warning { background: #D97706; }

/* --- Dashboard Premium UI Enhancements --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    position: relative;
    padding: 1.25rem 1.75rem;
    background: var(--surface);
    border-radius: 1.25rem;
    border: 1px solid var(--surface-border);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 100px;
    height: 100px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.04;
    z-index: 0;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.kpi-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.125rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}


.quick-actions-panel {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 1.25rem;
    padding: 1.25rem 2rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
}

.action-group {
    display: flex;
    gap: 1rem;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modern-card {
    background: var(--surface);
    border-radius: 1.25rem;
    border: 1px solid var(--surface-border);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    overflow: hidden;
    padding: 1.5rem;
    color: var(--text);
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.modern-table thead {
    background: var(--surface-hover);
    border-bottom: 3px solid var(--surface-border);
}

.modern-table th {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.075em;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
    text-align: left;
}

.modern-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--surface-border);
    vertical-align: middle;
}

.modern-table tr {
    transition: background 0.2s ease;
}

.modern-table tr:hover {
    background: #f8fafc;
}

.modern-table tr:last-child td {
    border-bottom: none;
}

/* ─── Password Input Toggle Button ──────────────── */
.password-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-container .form-control {
    padding-right: 48px !important;
}

.password-toggle-btn {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
    width: 24px;
    height: 24px;
    outline: none;
}

.password-toggle-btn:hover {
    color: var(--primary);
}

.password-toggle-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.password-toggle-btn .hidden {
    display: none !important;
}

/* =====================================================
   Responsiveness & Screen Breakpoints (5-Tier Support)
   ===================================================== */

/* ─── 1. Desktop & Laptop: 1024px iyo ka weyn ────────── */
@media (min-width: 1024px) {
    :root {
        --content-padding: 28px;
        --card-padding: 24px;
    }
    .sidebar {
        width: var(--sidebar-width) !important;
        left: 0 !important;
    }
    .main-content {
        margin-left: var(--sidebar-width) !important;
    }
    .sidebar-toggle {
        display: none !important; /* Hide hamburger menu on desktop/laptop */
    }
}

/* ─── 2. Shared Mobile & Tablet Overrides (max-width: 1023px) ─── */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1050 !important;
    }
    .sidebar.show {
        transform: translateX(0) !important;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .content-area {
        max-width: 100% !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1040;
    }
    .sidebar-overlay.show {
        display: block !important;
    }
    .sidebar-toggle {
        display: flex !important;
    }
    .sidebar-close-btn {
        display: flex !important;
    }
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .table-wrapper table {
        min-width: 700px;
    }
}

/* ─── 3. Tablet specific styles: 768px–1023px ─────────── */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --content-padding: 20px;
        --card-padding: 20px;
    }
    .hide-tablet {
        display: none !important;
    }
}

/* ─── 4. Large Mobile specific styles: 481px–767px ─────── */
@media (min-width: 481px) and (max-width: 767px) {
    :root {
        --content-padding: 16px;
        --card-padding: 20px;
    }
    html {
        font-size: 13px;
    }
    .page-header h1 {
        font-size: 1.5rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }
    .dashboard-grid, 
    .form-row, 
    .grid-2, 
    .grid-3, 
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .form-actions {
        flex-direction: column;
        gap: 8px !important;
    }
    .form-actions .btn, 
    .form-actions a {
        width: 100%;
        justify-content: center;
    }
    .quick-actions-panel {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 1.25rem !important;
        gap: 1.25rem !important;
    }
    .quick-actions-panel .action-group {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    .quick-actions-panel .action-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    .charts-grid {
        grid-template-columns: 1fr !important;
    }
    .hide-mobile {
        display: none !important;
    }
}

/* ─── 5. Mobile specific styles: 320px–480px ─────────── */
@media (max-width: 480px) {
    :root {
        --content-padding: 12px;
        --card-padding: 16px;
    }
    html {
        font-size: 12px;
    }
    .page-header h1 {
        font-size: 1.35rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    .page-actions {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    .page-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .dashboard-grid, 
    .form-row, 
    .grid-2, 
    .grid-3, 
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .form-actions {
        flex-direction: column;
        gap: 8px !important;
    }
    .form-actions .btn, 
    .form-actions a {
        width: 100%;
        justify-content: center;
    }
    .top-bar-right span {
        display: none; /* Hide username, keep only user icon */
    }
    .quick-actions-panel {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 1rem !important;
        gap: 1rem !important;
    }
    .quick-actions-panel .action-group {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    .quick-actions-panel .action-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    .charts-grid {
        grid-template-columns: 1fr !important;
    }
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
    .hide-mobile {
        display: none !important;
    }
    .dashboard-welcome-title {
        font-size: 1.45rem !important;
        line-height: 1.25 !important;
    }
    .dashboard-welcome-subtitle {
        font-size: 0.875rem !important;
        margin-top: 0.375rem !important;
    }
}

/* Dashboard Welcome Header */
.dashboard-welcome-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.025em;
    transition: var(--transition);
}

.dashboard-welcome-subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
}





/* ════════════════════════════════════════════════════════
   Preclinic-Style Sidebar (New Layout)
   ════════════════════════════════════════════════════════ */

/* ─── Sidebar Logo Area ─────────────────────────────── */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;      /* center the logo */
    position: relative;           /* anchor for the absolute close button */
    gap: 10px;
    padding: 14px 48px;           /* horizontal space so the centered logo breathes */
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 64px;
    flex-shrink: 0;
}

.sidebar-logo-brand {
    display: flex;
    align-items: center;
    justify-content: center;      /* center the logo link inside the brand */
    flex: 1;
    min-width: 0;
}

.sidebar-logo .logo {
    display: inline-flex;
    align-items: center;
    height: 36px;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-logo .logo img {
    height: 34px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

.sidebar-logo .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-size: 18px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.sidebar-logo .logo-small,
.sidebar-logo .dark-logo {
    display: none;
}

[data-theme="dark"] .sidebar-logo .logo-normal {
    display: none;
}

[data-theme="dark"] .sidebar-logo .dark-logo {
    display: inline-flex;
}

[data-theme="dark"] .sidebar-logo .dark-logo img {
    filter: brightness(0) invert(1);
}

/* ─── Sidebar Toggle / Close Buttons ────────────────── */
.sidenav-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    padding: 0;
}

.sidenav-toggle-btn:hover {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.sidenav-toggle-btn .sidenav-arrow {
    display: inline-block;
    font-size: 20px;
    font-weight: 400;
    transition: transform 0.25s ease;
}

.sidebar-collapsed .sidenav-toggle-btn .sidenav-arrow {
    transform: rotate(180deg);
}

.sidebar-close {
    display: none;
    position: absolute;           /* pinned right — never pushes the centered logo */
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 28px;              /* bigger X */
    line-height: 1;
    cursor: pointer;
    color: var(--sidebar-text);
    padding: 10px 14px;           /* more space = bigger tap target */
    border-radius: 8px;
}

.sidebar-close:hover {
    color: var(--danger);
    background: rgba(255, 255, 255, 0.06);
}

/* ─── Sidebar Scrollable Inner ──────────────────────── */
.sidebar-inner {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

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

.sidebar-inner::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 4px;
}


/* ─── Organization Switcher (Sidebar Top) ───────────── */
.sidebar-top {
    position: relative;
    margin-bottom: 14px;
}

.sidebar-top-toggle {
    display: block;
    text-decoration: none;
}

.sidebar-top-body {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius);
    background: var(--sidebar-hover);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-top-body:hover {
    border-color: var(--primary-border);
}

.sidebar-top-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 15px;
}

.sidebar-top-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-top-info {
    flex: 1;
    min-width: 0;
}

.sidebar-top-info h6 {
    font-size: 13px;
    font-weight: 700;
    color: var(--sidebar-text-active);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-top-info p {
    font-size: 11px;
    color: var(--sidebar-text);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-top-arrow {
    flex-shrink: 0;
    font-size: 16px;
    color: var(--sidebar-text);
}

.sidebar-top-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 30;
    display: none;
}

.sidebar-top.open .sidebar-top-dropdown {
    display: block;
    animation: sidebar-dropdown-in 0.15s ease;
}

@keyframes sidebar-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar-top-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: default;
    transition: var(--transition);
}

.sidebar-top-option:hover {
    background: var(--surface-hover);
}

.sidebar-top-option-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sidebar-top-option-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--primary-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.sidebar-top-option-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-top-option-sub {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-top-option .check {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
}

.sidebar-top-option.selected .check {
    background: var(--primary);
    border-color: var(--primary);
}


/* ─── Sidebar Menu (Preclinic Style) ────────────────── */
.sidebar-menu > ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-menu li {
    list-style: none;
}

.sidebar-menu .menu-title {
    padding: 16px 12px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-text);
    opacity: 0.45;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    transition: var(--transition);
}

.sidebar-menu li a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-menu li a.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 700;
}

.sidebar-menu li a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-menu li a.logout-link {
    color: var(--danger);
}

.sidebar-menu .nav-menu-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    font-style: normal;
}

.sidebar-menu .menu-arrow {
    margin-left: auto;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease;
}

.sidebar-menu .menu-arrow::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translate(-1px, -1px);
}

.sidebar-menu li.submenu.open > a .menu-arrow::after {
    transform: rotate(225deg) translate(-1px, -1px);
}

.sidebar-menu li.submenu.open > a {
    color: var(--primary);
    font-weight: 700;
}

/* Submenu list */
.sidebar-menu li.submenu > ul {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 26px;
}

.sidebar-menu li.submenu.open > ul {
    max-height: 900px;
}

.sidebar-menu li.submenu > ul li a {
    padding: 8px 12px;
    font-size: 13px;
    margin: 1px 0;
}

.sidebar-menu li.submenu > ul li a.active::before {
    height: 14px;
}


/* ─── Sidebar Footer ────────────────────────────────── */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.trial-item {
    position: relative;
    background: linear-gradient(135deg, var(--primary-bg), var(--primary-border));
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}

.trial-item-icon {
    width: 42px;
    height: 42px;
    background: var(--surface);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
}

.trial-item h6 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}

.trial-item p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.trial-item .close-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.trial-item .close-icon:hover {
    color: var(--danger);
}

.sidebar-footer .db-indicator {
    margin-top: 10px;
    padding: 6px 10px;
    font-size: 10px;
    opacity: 0.7;
    text-align: center;
    border-top: 1px solid var(--surface-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Collapsed Sidebar (Mini Mode) ─────────────────── */
.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 14px 8px;
    gap: 8px;
}

.sidebar-collapsed .sidebar-logo-brand {
    flex: 0;
}

.sidebar-collapsed .sidebar-logo .logo-normal,
.sidebar-collapsed .sidebar-logo .dark-logo {
    display: none;
}

.sidebar-collapsed .sidebar-logo .logo-small {
    display: inline-flex;
}

.sidebar-collapsed .sidenav-toggle-btn {
    width: 28px;
    height: 28px;
}

.sidebar-collapsed .sidebar-close {
    display: none;
}

.sidebar-collapsed .sidebar-inner {
    padding: 8px;
}

.sidebar-collapsed .sidebar-top {
    display: none;
}

.sidebar-collapsed .menu-title {
    display: none;
}

.sidebar-collapsed .sidebar-menu li a > span {
    display: none;
}

.sidebar-collapsed .sidebar-menu li.submenu > ul {
    display: none;
}

.sidebar-collapsed .sidebar-menu li a {
    justify-content: center;
    padding: 10px;
}

.sidebar-collapsed .sidebar-menu li.submenu.open > a {
    color: var(--sidebar-text);
    font-weight: 500;
}

.sidebar-collapsed .trial-item {
    padding: 10px;
}

.sidebar-collapsed .trial-item h6,
.sidebar-collapsed .trial-item p,
.sidebar-collapsed .trial-item .close-icon {
    display: none;
}

.sidebar-collapsed .trial-item-icon {
    margin-bottom: 0;
}

.sidebar-collapsed .sidebar-footer .db-indicator {
    display: none;
}

/* ─── Mobile Sidebar Close Button ───────────────────── */
@media (max-width: 1023px) {
    .sidebar-close {
        display: inline-flex;
    }
}


/* ─── DataTables Empty State Message ───────────────── */
.dataTables_empty {
    text-align: center !important;
    padding: 40px 20px !important;
    color: var(--text-secondary) !important;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
}


/* ════════════════════════════════════════════════════════
   Enhanced Responsiveness — All Pages, Dashboard & Forms
   Optimised for any device (phone, tablet, laptop, desktop)
   ════════════════════════════════════════════════════════ */

/* ─── Global guard: no page-level horizontal scroll ── */
html, body {
    overflow-x: clip;
}
@supports not (overflow-x: clip) {
    html, body { overflow-x: hidden; }
}

/* ─── Auth pages (Login / Register / Reset / OTP) ─────── */
@media (max-width: 1023px) {
    .auth-wrapper {
        padding: 24px 16px;
    }
    .auth-card {
        width: 100%;
        max-width: 440px;
        padding: 40px 28px;
    }
}
@media (max-width: 480px) {
    .auth-card {
        padding: 30px 20px;
    }
    .auth-logo {
        margin-bottom: 28px;
    }
    .auth-logo h1 {
        font-size: 1.3rem;
    }
}

/* ─── Top Bar ─────────────────────────────────────────── */
@media (max-width: 767px) {
    .top-bar {
        height: 58px;
        padding: 0 12px;
    }
    .page-title {
        font-size: 15px;
        max-width: 45vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .top-bar-right {
        gap: 4px;
    }
    .profile-dropdown {
        right: -6px;
    }
}

/* ─── Cards & Spacing ─────────────────────────────────── */
@media (max-width: 767px) {
    .card {
        margin: 0.75rem;
    }
    .card-header {
        padding: 16px 18px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-footer {
        padding: 12px 16px;
    }
    .table-wrapper {
        margin: 0.75rem;
    }
    .page-header {
        margin-bottom: 16px;
    }
}
@media (max-width: 480px) {
    .card {
        margin: 0.5rem;
    }
    .card-header {
        padding: 14px;
    }
    .stats-grid {
        gap: 12px;
    }
    .stat-card {
        padding: 18px;
    }
    .stat-value {
        font-size: 24px;
    }
}

/* ─── Tables outside .table-wrapper become scrollable ─── */
@media (max-width: 767px) {
    .card-body > table,
    .card > table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-collapse: separate;
    }
    .card-body > table td,
    .card-body > table th,
    .card > table td,
    .card > table th {
        white-space: nowrap;
    }
    .table-wrapper thead th {
        padding: 10px 12px;
    }
    .table-wrapper tbody td {
        padding: 10px 12px;
    }
}

/* ─── Tabs ────────────────────────────────────────────── */
@media (max-width: 767px) {
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .tab {
        padding: 10px 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }
}


/* ─── Inline grids: collapse to one column on mobile ──── */
@media (max-width: 767px) {
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* ─── Forms, Filters & Search ─────────────────────────── */
@media (max-width: 767px) {
    .report-filters {
        padding: 16px;
        gap: 12px;
    }
    .report-filters .form-group {
        min-width: 100%;
    }
    .search-input-wrapper {
        min-width: 100%;
    }
    .form-actions {
        flex-wrap: wrap;
    }
    .input-group > * {
        min-width: 0;
    }
    .card-body[style*="padding: 2."],
    .card-body[style*="padding: 3."],
    .card-body[style*="padding: 4."] {
        padding: 1.25rem !important;
    }
}

/* ─── DataTables controls stack on mobile ─────────────── */
@media (max-width: 767px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        padding-bottom: 0 !important;
    }
    .dataTables_wrapper .dataTables_filter input {
        min-width: 0 !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 6px !important;
        box-sizing: border-box !important;
    }
    .dataTables_wrapper .dataTables_info {
        text-align: center !important;
        padding: 0.75rem 0 !important;
    }
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
    }
}

/* ─── Modals ──────────────────────────────────────────── */
@media (max-width: 767px) {
    .modal-content {
        padding: 1.5rem !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
    }
}

/* ─── Receipts / Statements / Ledger ──────────────────── */
@media (max-width: 767px) {
    .receipt-header {
        padding: 20px;
    }
    .receipt-body {
        padding: 20px;
    }
    .receipt-meta {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .statement-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 16px;
    }
}

/* ─── Export buttons & very small screens ─────────────── */
@media (max-width: 480px) {
    .table-export-actions {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .table-export-actions .btn {
        width: 100% !important;
    }
    .report-summary {
        gap: 10px;
    }
}


/* ─── Invoice Create: Items table responsive ─────────── */
@media (max-width: 767px) {
    #itemsTableWrapper {
        overflow: visible !important;
        border: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    #itemsTable {
        display: block !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    #itemsTable thead {
        display: none;
    }
    #itemsTable tbody {
        display: block;
        width: 100%;
    }
    #itemsTable .item-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 14px;
        margin: 0 0 12px;
        border: 1px solid var(--surface-border);
        border-radius: 12px;
        background: var(--surface);
    }
    #itemsTable .item-row td {
        display: block;
        padding: 0;
        border: none;
    }
    /* Show the column name as a small label above each field */
    #itemsTable .item-row td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
        margin-bottom: 4px;
    }
    #itemsTable .item-row td:first-child {
        grid-column: 1 / -1;
    }
    #itemsTable .item-row td:last-child {
        grid-column: 1 / -1;
        text-align: right;
    }
    #itemsTable .item-name-select + .select2-container,
    #itemsTable .select2-container {
        width: 100% !important;
        max-width: 100% !important;
    }
    #itemsTable .form-control {
        min-width: 0;
    }
}


/* ─── Invoice Create: Items table column spacing ──────── */
@media (min-width: 768px) {
    #itemsTable {
        table-layout: fixed;
    }
    #itemsTable thead th {
        padding: 12px 14px;
        white-space: nowrap;
    }
    #itemsTable tbody td {
        padding: 12px 10px;
        vertical-align: middle;
        white-space: nowrap;
    }
    #itemsTable td:nth-child(3) {
        text-align: center;
    }
    #itemsTable td:nth-child(5) {
        text-align: right;
    }
    #itemsTable td:nth-child(6) {
        text-align: right;
    }
    #itemsTable .form-control {
        padding: 9px 12px;
    }
    #itemsTable .item-total {
        display: inline-block;
        min-width: 80px;
        text-align: right;
        font-weight: 700;
        font-size: 13.5px;
    }
}


/* ─── Alerts Page Responsive ─────────────────────────── */
.alerts-grid {
    gap: 20px;
    /* minmax(0,1fr) stops long table content from blowing the card wider
       than the grid track on smaller laptop screens */
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Tablets (768px–1023px): full-width cards, tables size to the card
   instead of forcing a 700px sideways scroll. */
@media (max-width: 1023px) {
    .alerts-grid {
        grid-template-columns: 1fr !important;
    }
    /* Override the global ".table-wrapper table { min-width:700px }" rule so
       alert tables fit their card width naturally. */
    .alerts-grid table.display {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

/* Phones (<768px): tables become responsive stacked cards. */
@media (max-width: 767px) {
    .alerts-grid {
        gap: 14px !important;
    }
    .alerts-grid .card-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px 16px;
    }
    .alerts-grid .card-title {
        font-size: 14px;
        line-height: 1.35;
    }
    /* Compact empty states */
    .alerts-grid .card-body > div[style*="padding: 40px"] {
        padding: 28px 16px !important;
    }
    .alerts-grid .card-body > div[style*="padding: 40px"] div[style*="font-size: 2.5rem"] {
        font-size: 2rem !important;
        margin-bottom: 8px !important;
    }
    .alerts-grid .card-body > div[style*="padding: 40px"] h4 {
        font-size: 1.05rem;
    }

    /* DataTables → responsive stacked cards */
    .alerts-grid .table-wrapper {
        border: none;
        margin: 0;
        padding: 6px 12px 16px;
        overflow: visible;
    }
    /* DataTables writes an inline width:0px on the table while measuring
       columns; !important guarantees the cards stretch full-width anyway. */
    .alerts-grid table.display {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    .alerts-grid table.display thead {
        display: none !important;
    }
    .alerts-grid table.display tbody {
        display: block !important;
        width: 100% !important;
    }
    .alerts-grid table.display tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
        padding: 14px;
        margin: 0 0 12px;
        border: 1px solid var(--surface-border);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    }
    .alerts-grid table.display tbody tr:hover {
        background: var(--surface-hover);
    }
    .alerts-grid table.display tbody td {
        display: block;
        padding: 0 !important;
        border: none;
        text-align: left !important;
        white-space: normal;
        min-width: 0;
        overflow-wrap: break-word;
    }
    /* Column name label above each field */
    .alerts-grid table.display tbody td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
        margin-bottom: 3px;
    }
    /* Medicine / Invoice name spans full width (ID column is removed from
       the DOM by DataTables, so the name is the 1st visible cell) */
    .alerts-grid table.display tbody tr td:nth-child(1) {
        grid-column: 1 / -1;
        padding-bottom: 2px !important;
    }
    /* Action button row — full width, right aligned */
    .alerts-grid table.display tbody tr td:last-child {
        grid-column: 1 / -1;
        text-align: right !important;
        padding-top: 2px !important;
    }
    /* DataTables "no data" message */
    .alerts-grid table.display .dataTables_empty {
        grid-column: 1 / -1;
        text-align: center !important;
        padding: 24px 16px !important;
    }

    /* DataTables toolbar rows inside alert cards */
    .alerts-grid .dataTables_length,
    .alerts-grid .dataTables_filter {
        padding: 0 0 10px !important;
    }
    .alerts-grid .dataTables_info {
        padding-top: 2px !important;
        font-size: 11.5px !important;
    }
    .alerts-grid .dataTables_paginate {
        padding-top: 8px !important;
    }

    /* Excel / PDF export buttons wrap instead of overflowing */
    .alerts-grid .table-export-actions {
        flex-wrap: wrap;
        justify-content: flex-start !important;
        padding: 0 12px;
        margin-bottom: 10px !important;
    }
}


/* ─── Premium Dashboard Header Responsive ────────────── */
.dashboard-header .row {
    gap: 16px;
}
@media (max-width: 767px) {
    .dashboard-header .row {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .dashboard-header .no-print {
        width: 100%;
    }
    .dashboard-header .segmented-control {
        width: 100%;
    }
    .dashboard-header .segmented-control .btn {
        flex: 1;
        justify-content: center;
    }
    .dashboard-welcome-title {
        font-size: 1.5rem !important;
        line-height: 1.25 !important;
    }
}
@media (max-width: 480px) {
    .dashboard-header .row {
        gap: 10px;
    }
    .dashboard-welcome-title {
        font-size: 1.35rem !important;
    }
    .dashboard-welcome-subtitle {
        font-size: 0.85rem !important;
    }
}


/* ─── Missing utility classes used by views ──────────── */
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.max-w-xs { max-width: 20rem; }
.max-w-2xl { max-width: 42rem; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-block { display: inline-block; }
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ─── Fix: content stuck to left / clipped on right (mobile) ── */
@media (max-width: 767px) {
    /* Neutralise .row negative margins (pulled content to the edges) */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Cards must never exceed the viewport */
    .card,
    .modern-card,
    .kpi-card,
    .stat-card,
    .report-summary-item {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    /* Wide tables inside cards become horizontally scrollable */
    .card table,
    .modern-card table,
    .card-body table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-collapse: separate;
    }
    .card table td,
    .card table th,
    .modern-card table td,
    .modern-card table th,
    .card-body table td,
    .card-body table th {
        white-space: nowrap;
    }

    /* Tables already inside scroll wrappers keep normal layout */
    .table-wrapper table,
    .table-responsive table {
        display: table;
        white-space: normal;
        min-width: 700px;
    }

    /* Charts / canvases */
    .chart-container {
        max-width: 100%;
        overflow: hidden;
    }
    canvas {
        max-width: 100% !important;
    }
}


/* ─── Date inputs: clear dd/mm/yyyy hint when empty ─── */
input[type="date"] {
    position: relative;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.7;
}
/* Empty → hide the browser default hint, show our dd/mm/yyyy */
input[type="date"].date-empty:not(:focus):not([placeholder=""])::-webkit-datetime-edit {
    color: transparent;
}
input[type="date"].date-empty:not(:focus):not([placeholder=""])::before {
    content: attr(placeholder);
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13.5px;
    font-family: var(--font);
    pointer-events: none;
    white-space: nowrap;
    max-width: calc(100% - 60px);
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Picked date → normal text colour */
input[type="date"]:not(.date-empty)::-webkit-datetime-edit {
    color: var(--text);
}


/* ─── Dashboard: Recent Invoices & Latest Payments (responsive) ─── */
/* Stack the two tables into one column before they get too narrow */
@media (max-width: 1279px) {
    .dashboard-tables-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Let each card shrink below the table's intrinsic width so the table
   scrolls inside the card instead of overflowing the page */
.dashboard-tables-grid > div {
    min-width: 0;
}

/* On phones: keep table cells scrollable and reduce card padding */
@media (max-width: 767px) {
    .dashboard-tables-grid .modern-card {
        padding: 1rem;
    }
}

