/* ============================================
   MediShop Pro - Main Stylesheet
   Modern Medical Dashboard UI
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #6366f1;
    --dark: #0f172a;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f1f5f9;
    --white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.10);
    --transition: all .2s ease;
    --glass: rgba(255,255,255,.72);
    --glass-border: rgba(255,255,255,.5);
}

/* ─── Lucide Icons ───────────────────────────────────────
   Icons size themselves to the font-size of their container
   (1em), so every spot that previously sized an emoji via
   font-size keeps the exact same visual size automatically. */
[data-lucide], svg.lucide {
    display: inline-block;
    width: 1em;
    height: 1em;
    stroke-width: 2;
    vertical-align: -0.15em;
    flex-shrink: 0;
    color: currentColor;
}

/* Dark mode */
body.dark {
    --primary-light: #1e3a5f;
    --dark: #f8fafc;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --bg: #0f172a;
    --white: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
    --glass: rgba(30,41,59,.8);
    --glass-border: rgba(100,116,139,.3);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    transition: background .3s, color .3s;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease, width .3s ease;
    overflow: hidden;
}

body.dark .sidebar { background: #020617; border-right: 1px solid var(--border); }

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand h2 {
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.3px;
}

.sidebar-brand span {
    color: rgba(255,255,255,.5);
    font-size: 11px;
    display: block;
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.nav-section-title {
    color: rgba(255,255,255,.35);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 6px;
    margin-top: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.65);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }

.nav-link .nav-icon {
    width: 20px;
    font-size: 16px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,.06);
}

.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

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

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: rgba(255,255,255,.45); font-size: 11px; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left .3s ease;
}

/* Top Header */
.topbar {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; }

.menu-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    display: none;
}

.menu-toggle:hover { background: var(--bg); color: var(--text); }

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

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

.topbar-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
    font-size: 18px;
}

.topbar-btn:hover { background: var(--bg); color: var(--text); }

.notif-badge {
    position: absolute;
    top: 4px; right: 4px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--white);
}

.page-content { padding: 24px; }

/* ─── Cards ────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

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

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-card.blue::before { background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.orange::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.red::before { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--info), #8b5cf6); }
.stat-card.teal::before { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }

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

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

.stat-card.blue .stat-icon { background: #eff6ff; color: var(--primary); }
.stat-card.green .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-card.orange .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-card.red .stat-icon { background: #fef2f2; color: var(--danger); }
.stat-card.purple .stat-icon { background: #eef2ff; color: var(--info); }
.stat-card.teal .stat-icon { background: #f0fdfa; color: #14b8a6; }

.stat-info { flex: 1; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── Tables ────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-light); }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #f0fdf4; color: #16a34a; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-danger  { background: #fef2f2; color: #dc2626; }
.badge-info    { background: #eef2ff; color: #4f46e5; }
.badge-muted   { background: var(--bg); color: var(--text-muted); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline-primary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

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

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

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    color: var(--text);
    transition: var(--transition);
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

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

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control { flex: 1; border-radius: 8px 0 0 8px; }
.input-group .input-group-btn { border-radius: 0 8px 8px 0; }

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

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(.96) translateY(8px);
    transition: var(--transition);
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

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

.modal-title { font-size: 17px; font-weight: 700; }

.modal-close {
    background: var(--bg);
    border: none;
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

/* ─── Toast ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 80px; right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--white);
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 300px;
    max-width: 380px;
    pointer-events: all;
    animation: toastIn .3s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

.toast-icon { font-size: 18px; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }

.toast-text { flex: 1; }
.toast-title { font-weight: 700; font-size: 13.5px; }
.toast-msg { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ─── Search & Filters ──────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    padding-left: 38px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ─── Pagination ────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.page-btn {
    width: 34px; height: 34px;
    border: 1.5px solid var(--border);
    background: var(--white);
    border-radius: 7px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.page-info { font-size: 13px; color: var(--text-muted); margin-right: auto; }

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; margin-bottom: 20px; }

/* ─── Chart Containers ──────────────────────────────────── */
.chart-container { position: relative; width: 100%; }
.chart-container canvas { max-width: 100%; }

/* ─── Auth Pages ────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #0ea5e9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

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

.auth-logo .logo-icon {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 12px;
}

.auth-logo h1 { font-size: 24px; font-weight: 800; color: var(--dark); }
.auth-logo p { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }

.auth-tabs {
    display: flex;
    background: var(--bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 24px;
    gap: 4px;
}

.auth-tab {
    flex: 1;
    padding: 9px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

/* ─── File Upload ───────────────────────────────────────── */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.file-upload-area:hover, .file-upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-area input[type="file"] { display: none; }
.file-upload-preview { max-width: 80px; max-height: 80px; border-radius: 8px; margin-top: 8px; }

/* ─── Alert Boxes ───────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
}

.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Loader ────────────────────────────────────────────── */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark .loader-overlay { background: rgba(15,23,42,.8); }

.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

/* ─── Notification Dropdown ─────────────────────────────── */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 200;
    display: none;
}

.notif-dropdown.show { display: block; animation: toastIn .2s ease; }

.notif-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    transition: var(--transition);
    cursor: pointer;
}

.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-msg { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ─── Profile Dropdown ──────────────────────────────────── */
.topbar-profile { position: relative; cursor: pointer; }

.profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 200;
    display: none;
    overflow: hidden;
}

.profile-menu.show { display: block; animation: toastIn .2s ease; }

.profile-menu a, .profile-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    transition: var(--transition);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.profile-menu a:hover, .profile-menu button:hover { background: var(--bg); }
.profile-menu .divider { height: 1px; background: var(--border); }
.profile-menu .logout-btn { color: var(--danger); }

/* ─── Invoice Print Styles ──────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .filters-bar, .pagination { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 260px; }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content { margin-left: 0; }
    .menu-toggle { display: flex !important; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .auth-card { padding: 28px 20px; }
    .modal { max-width: 100%; margin: 16px; }
    .notif-dropdown { width: 300px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar .search-box { min-width: unset; }
}

/* ─── Overlay for mobile sidebar ───────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

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

/* ─── Misc ──────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.fw-bold     { font-weight: 700; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.w-100 { width: 100%; }

/* ─── Invoice Print Specific ────────────────────────────── */
@media print {
    body { background: white !important; color: #000 !important; }
    .sidebar, .topbar, .btn, .filters-bar, .pagination,
    .topbar-right, .menu-toggle, .sidebar-overlay,
    [onclick], .card-header .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
    .card-header { background: white !important; }
    table { border-collapse: collapse; }
    th, td { border: 1px solid #ddd; padding: 8px 12px; }
    .badge { border: 1px solid currentColor; }
    @page { margin: 10mm; size: A4; }
}

/* ─── Skeleton Loader ───────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── Progress bars ─────────────────────────────────────── */
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width .6s ease; }
.progress-bar.blue   { background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.progress-bar.green  { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-bar.orange { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.progress-bar.red    { background: linear-gradient(90deg, var(--danger), #f87171); }

/* ─── Quick stats mini ──────────────────────────────────── */
.mini-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.mini-stat:last-child { border-bottom: none; }
.mini-stat-label { font-size: 13px; color: var(--text-muted); }
.mini-stat-value { font-size: 14px; font-weight: 700; }

/* ─── Scrollbar styling ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Input focus glow on dark ──────────────────────────── */
body.dark .form-control { background: #1e293b; border-color: var(--border); color: var(--text); }
body.dark .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.2); }
body.dark thead th { background: #1e293b; }
body.dark .auth-card { background: rgba(15,23,42,.85); }

/* ─── Table row hover for dark ──────────────────────────── */
body.dark tbody tr:hover { background: rgba(37,99,235,.08); }

/* ─── Floating action button ────────────────────────────── */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px; height: 52px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37,99,235,.4);
    border: none;
    transition: var(--transition);
    z-index: 50;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.08); }

/* ─── Status indicator dot ──────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.warning { background: var(--warning); }

/* ─── Tooltip ───────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Horizontal divider with text ─────────────────────── */
.divider-text {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    margin: 16px 0;
}
.divider-text::before, .divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ─── Image avatar ──────────────────────────────────────── */
.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    font-size: 16px;
    flex-shrink: 0;
}

/* ─── Table actions toolbar ─────────────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ─── Grid utilities ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

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

/* ─── Highlight row ─────────────────────────────────────── */
tr.highlight-new { animation: rowFlash 1.5s ease; }
@keyframes rowFlash {
    0%   { background: rgba(16,185,129,.15); }
    100% { background: transparent; }
}
