/* ============================================================
   Business CRM - Premium Design System
   ============================================================ */

/* ─── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Custom Properties ────────────────────────────────── */
:root {
    /* Primary palette - More Vibrant & Professional */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);

    /* Accent - Stunning Teal/Cyan */
    --accent: #06b6d4;
    --accent-light: #22d3ee;
    --accent-glow: rgba(6, 182, 212, 0.2);

    /* Success / Warning / Danger - Balanced & High Contrast */
    --success: #10b981;
    --success-light: #34d399;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --danger: #ef4444;
    --danger-light: #f87171;

    /* Dark mode colors - Deep, rich layering */
    --bg-body: #0b0d12;
    --bg-sidebar: #11141d;
    --bg-card: #161a26;
    --bg-card-hover: #1c2231;
    --bg-input: #1c2231;
    --bg-modal: #161a26;

    /* Borders - Subtle but defined */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);

    /* Text - Crisp and readable */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dark: #0f172a;

    /* Gradients - Premium 2024 Aesthetics */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --blur: blur(20px);

    /* Shadows - Layered for depth */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-primary: 0 0 20px rgba(99, 102, 241, 0.2);

    /* Layout & Radius */
    --sidebar-width: 260px;
    --sidebar-collapsed: 74px;
    --topbar-height: 70px;
    --bottom-nav-height: 70px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.2s ease;
}

/* ─── Light Theme Overrides - High-End Corporate Look ────────── */
body.light-theme {
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f8fafc;
    --bg-modal: #ffffff;

    --border-color: #e2e8f0;
    --border-light: #cbd5e1;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-dark: #020617;

    --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.7) 100%);
    --bg-glass: rgba(255, 255, 255, 0.8);
    --blur: blur(10px);

    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.08);
}

body.light-theme .topbar {
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid #e2e8f0;
}

body.light-theme .stat-card {
    box-shadow: var(--shadow-sm);
}

body.light-theme .stat-card:hover {
    box-shadow: var(--shadow-md);
}

body.light-theme .table th {
    background: #f1f5f9;
}

body.light-theme .topbar-user {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

body.light-theme .upgrade-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

body.light-theme .upgrade-box h3 {
    color: #0f172a;
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--accent-light);
}

img {
    max-width: 100%;
}

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ─── Layout ───────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    transition: var(--transition);
    min-height: 100vh;
}

body.light-theme .sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
}

body.light-theme .sidebar-header {
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .nav-section-title {
    color: #94a3b8;
}

body.light-theme .nav-item:hover {
    background: #f1f5f9;
}

body.light-theme .card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

body.light-theme .form-control {
    border-color: var(--border-color);
}

body.light-theme .table td,
body.light-theme .table th {
    border-color: var(--border-color);
}

body.light-theme .topbar-user {
    border: 1px solid var(--border-color);
}

.content-area {
    padding: 28px;
    max-width: 1400px;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1001;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 65px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    transition: var(--transition);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.sidebar-collapsed .sidebar-brand {
    opacity: 0;
    width: 0;
}

.sidebar-nav {
    padding: 12px 10px;
    flex: 1;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 8px 14px 6px;
    white-space: nowrap;
    overflow: hidden;
}

body.sidebar-collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
    white-space: nowrap;
    position: relative;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
}

.nav-item.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;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

body.sidebar-collapsed .nav-item span:not(.nav-icon) {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ─── Topbar ───────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: rgba(15, 17, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    transition: var(--transition);
}

body.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.topbar-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.topbar-user:hover {
    background: rgba(255, 255, 255, 0.07);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
}

.user-info {
    line-height: 1.3;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── Page Header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* ─── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.gradient-1::before {
    background: var(--gradient-primary);
    opacity: 1;
}

.stat-card.gradient-2::before {
    background: var(--gradient-accent);
    opacity: 1;
}

.stat-card.gradient-3::before {
    background: var(--gradient-success);
    opacity: 1;
}

.stat-card.gradient-4::before {
    background: var(--gradient-warm);
    opacity: 1;
}

/* ─── Rich Vibrant Gradients for Dashboard Cards ─── */
.bg-grad-purple {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%) !important;
    color: white !important;
    border: none !important;
}

.bg-grad-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    color: white !important;
    border: none !important;
}

.bg-grad-green {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%) !important;
    color: white !important;
    border: none !important;
}

.bg-grad-orange {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: white !important;
    border: none !important;
}

.bg-grad-red {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    color: white !important;
    border: none !important;
}

.bg-grad-slate {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important;
    color: white !important;
    border: none !important;
}

.bg-grad-purple .stat-label,
.bg-grad-blue .stat-label,
.bg-grad-green .stat-label,
.bg-grad-orange .stat-label,
.bg-grad-red .stat-label,
.bg-grad-slate .stat-label,
.bg-grad-purple .text-muted,
.bg-grad-blue .text-muted,
.bg-grad-green .text-muted,
.bg-grad-orange .text-muted,
.bg-grad-red .text-muted,
.bg-grad-slate .text-muted {
    color: rgba(255, 255, 255, 0.9) !important;
}

.bg-grad-purple .stat-icon,
.bg-grad-blue .stat-icon,
.bg-grad-green .stat-icon,
.bg-grad-orange .stat-icon,
.bg-grad-red .stat-icon,
.bg-grad-slate .stat-icon {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.bg-grad-purple::before,
.bg-grad-blue::before,
.bg-grad-green::before,
.bg-grad-orange::before,
.bg-grad-red::before,
.bg-grad-slate::before {
    display: none !important;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.stat-icon.purple {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary-light);
}

.stat-icon.cyan {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.stat-icon.amber {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    color: white;
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-light);
    color: white;
}

.btn-warning {
    background: var(--gradient-warm);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ─── Forms ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Global Select & Option Theme Fix */
select {
    cursor: pointer;
}

select option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* For browsers that support styling the focused option */
select:focus option:checked {
    background: var(--primary) !important;
    color: #fff !important;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* ─── Tables ───────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

.table .actions {
    display: flex;
    gap: 6px;
}

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-light);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning-light);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger-light);
}

.badge-primary {
    background: var(--primary-glow);
    color: var(--primary-light);
}

.badge-info {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-light);
}

/* ─── Alerts / Flash Messages ──────────────────────────────── */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success-light);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger-light);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning-light);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: var(--accent-light);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 18px;
}

.alert-close:hover {
    opacity: 1;
}

/* ─── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* ─── Search Bar ───────────────────────────────────────────── */
.search-bar {
    position: relative;
    max-width: 350px;
}

.search-bar input {
    padding-left: 40px;
}

.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

/* ─── Empty State ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 8px;
}

/* ─── Auth Pages ───────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-body);
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    border-radius: 50%;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    background: var(--gradient-primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.auth-logo h1 {
    font-size: 22px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.auth-form .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
    margin-top: 6px;
}

.auth-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary-light);
    font-weight: 600;
}

/* ─── Invoice Print Styles ─────────────────────────────────── */
.invoice-page {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    color: #1a1a2e;
    padding: 40px;
    border-radius: var(--radius-lg);
}

.invoice-page * {
    color: #1a1a2e;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.invoice-brand h2 {
    font-size: 24px;
    color: #4f46e5;
    margin-bottom: 4px;
}

.invoice-brand p {
    font-size: 13px;
    color: #64748b;
}

.invoice-meta {
    text-align: right;
}

.invoice-meta h3 {
    font-size: 20px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.invoice-meta p {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.invoice-party h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.invoice-party p {
    font-size: 14px;
    line-height: 1.6;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.invoice-table th {
    background: #f1f5f9;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
}

.invoice-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.invoice-total {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 32px;
}

.invoice-total table {
    width: 280px;
}

.invoice-total td {
    padding: 8px 16px;
    font-size: 14px;
}

.invoice-total .grand-total td {
    font-size: 18px;
    font-weight: 700;
    color: #4f46e5;
    border-top: 2px solid #4f46e5;
    padding-top: 12px;
}

.invoice-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
    font-size: 13px;
}

.invoice-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

@media print {
    body {
        background: white !important;
    }

    .sidebar,
    .topbar,
    .invoice-actions {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    .content-area {
        padding: 0 !important;
    }

    .invoice-page {
        box-shadow: none !important;
        padding: 20px !important;
    }
}

/* ─── Animations ───────────────────────────────────────────── */
@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

/* ─── Grid Helpers ─────────────────────────────────────────── */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ─── Utility Classes ──────────────────────────────────────── */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-primary {
    color: var(--primary-light) !important;
}

.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;
}

.gap-2 {
    gap: 16px;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

/* ─── Low Stock Indicator ──────────────────────────────────── */
.stock-low {
    color: var(--danger);
    font-weight: 600;
}

.stock-ok {
    color: var(--success);
}

/* ─── Checkbox Select All ──────────────────────────────────── */
.customer-select {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.customer-select label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 14px;
}

.customer-select label:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* ─── Dynamic Line Items ───────────────────────────────────── */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
}

.line-items-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.line-items-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.line-items-table input,
.line-items-table select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.btn-remove {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger) !important;
    color: white !important;
    border: none !important;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition-fast);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-remove:hover {
    background: var(--danger-light) !important;
    color: white !important;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.line-total {
    text-align: right;
    padding: 8px 12px;
    font-weight: 600;
    min-width: 100px;
}

#add-item-btn {
    margin-top: 12px;
}

/* ─── Dashboard Stats ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

/* ─── Responsive Utilities ─────────────────────────────────── */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: inline-flex !important;
}

/* ─── Sidebar Overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 992px) {

    /* Toggle button visibility */
    .mobile-only {
        display: inline-flex !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Sidebar: hidden by default, slides in */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    /* Reset collapsed state on mobile */
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    body.sidebar-collapsed.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar-brand {
        opacity: 1;
        width: auto;
    }

    body.sidebar-collapsed .nav-section-title {
        opacity: 1;
        height: auto;
        padding: 8px 14px 6px;
    }

    body.sidebar-collapsed .nav-item span:not(.nav-icon) {
        opacity: 1;
        width: auto;
    }

    /* Main content: full width */
    .main-content {
        margin-left: 0 !important;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }

    /* Topbar: full width */
    .topbar {
        left: 0 !important;
    }

    body.sidebar-collapsed .topbar {
        left: 0 !important;
    }

    .topbar {
        padding: 0 16px;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    /* Grids */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Dashboard date filter */
    .dash-filter-form {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .dash-filter-form h4 { font-size: 15px !important; }
    .dash-filter-right {
        width: 100%;
        margin-left: 0 !important;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    .dash-filter-right .form-control {
        width: 100% !important;
    }
    .dash-filter-right .form-group {
        flex: 1 1 calc(50% - 4px);
        min-width: 130px;
    }

    /* Dashboard quick actions */
    .dash-quick-actions .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Invoice */
    .invoice-parties {
        grid-template-columns: 1fr;
    }

    /* Customer insights — 2 col on tablet */
    .cust-insights-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Hide non-critical table columns on tablet */
    .table-hide-tablet { display: none !important; }
}

@media (max-width: 576px) {

    /* Content area — no horizontal overflow */
    html, body { overflow-x: hidden; }
    .main-content { overflow-x: hidden; }
    .content-area {
        padding: 14px;
        overflow-x: hidden;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Topbar */
    .topbar {
        padding: 0 12px;
        height: 56px;
    }

    .main-content {
        padding-top: 56px;
    }

    .topbar-title {
        font-size: 15px;
    }

    .topbar-right .badge {
        display: none;
    }

    .topbar-user .user-info {
        display: none;
    }

    .topbar-user {
        padding: 4px 8px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* Stats grid - 2 cards visible at a time, swipeable */
    .stats-grid {
        display: flex !important;
        overflow-x: auto;
        gap: 12px;
        padding: 4px 14px 20px 14px;
        margin: 0 -14px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .stats-grid::-webkit-scrollbar {
        display: none;
    }

    .stat-card {
        flex: 0 0 calc(50vw - 22px);
        min-width: 160px;
        max-width: 220px;
        padding: 16px 14px;
        scroll-snap-align: start;
        margin-bottom: 0 !important;
    }

    .stat-value {
        font-size: 20px;
        letter-spacing: -0.5px;
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-bottom: 8px;
    }

    .stat-card .mt-3 {
        margin-top: 10px !important;
        padding-top: 10px !important;
        font-size: 11px !important;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .page-title {
        font-size: 20px;
    }

    .page-actions {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    /* Override any inline min-width on search forms inside page-actions */
    .page-actions form {
        min-width: 0 !important;
        width: 100%;
    }

    .page-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 11px 16px;
        font-size: 14px;
    }

    /* Auth pages */
    .auth-card {
        padding: 28px 20px;
    }

    /* Tables */
    .table-wrapper {
        margin: 0 -14px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .table .actions {
        flex-direction: column;
        gap: 4px;
    }

    .table .actions .btn-sm {
        padding: 4px 10px;
        font-size: 12px;
    }

    /* Cards */
    .card {
        padding: 16px;
        border-radius: var(--radius-sm);
    }

    .card-header {
        margin-bottom: 14px;
        padding-bottom: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-group {
        margin-bottom: 14px;
    }

    /* Modals */
    .modal {
        padding: 20px;
        width: 95%;
        max-height: 90vh;
    }

    /* Invoice page */
    .invoice-page {
        padding: 20px;
    }

    .invoice-header {
        flex-direction: column;
        gap: 16px;
    }

    .invoice-meta {
        text-align: left;
    }

    .invoice-actions {
        flex-direction: column;
    }

    .invoice-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .invoice-total table {
        width: 100%;
    }

    /* Line items */
    .line-items-table th,
    .line-items-table td {
        padding: 6px 8px;
        font-size: 12px;
    }

    .line-items-table input,
    .line-items-table select {
        padding: 6px 8px;
        font-size: 12px;
    }

    .main-content {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 20px);
    }

    /* grid-4 → 2 columns on mobile */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* Customer insights + WA stats grid */
    .cust-insights-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .cust-insights-grid > * {
        padding: 20px 14px !important;
    }

    /* Dashboard filter: stacked */
    .dash-filter-form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 14px !important;
    }
    .dash-filter-form h4 {
        font-size: 14px !important;
        margin-bottom: 0 !important;
    }
    .dash-filter-right {
        width: 100% !important;
        margin-left: 0 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        align-items: end;
    }
    .dash-filter-right .form-group {
        margin-bottom: 0 !important;
    }
    .dash-filter-right .form-control {
        width: 100% !important;
        font-size: 13px !important;
        padding: 8px 10px !important;
        height: 38px !important;
    }
    .dash-filter-right label {
        font-size: 10px !important;
    }
    .dash-filter-actions {
        grid-column: 1 / -1;
        display: flex !important;
        gap: 8px !important;
    }
    .dash-filter-actions .btn {
        flex: 1 !important;
        height: 38px !important;
        font-size: 13px !important;
        justify-content: center !important;
    }

    /* Quick shortcuts — compact 2x2 */
    .dash-quick-actions .btn {
        height: 46px !important;
        font-size: 12px !important;
        padding: 0 10px !important;
        border-radius: 10px !important;
    }
    .dash-quick-actions .btn i {
        font-size: 14px !important;
        margin-right: 4px !important;
    }
    .dash-quick-actions h3 {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }
    .dash-quick-actions .mb-4 {
        margin-bottom: 12px !important;
    }

    /* Performance chart smaller */
    .dash-chart-body {
        height: 220px !important;
    }

    /* Analytics panels */
    .glass-panel .p-4 {
        padding: 14px !important;
    }
    .glass-panel .p-5 {
        padding: 20px !important;
    }

    /* Recent Invoices — hide Date col on mobile */
    .recent-invoices-date { display: none !important; }

    /* Analytics big numbers smaller */
    .dash-big-num { font-size: 24px !important; }

    /* WA stats */
    .wa-stat-num { font-size: 22px !important; }

    /* Section titles */
    .glass-panel h4 { font-size: 14px !important; }
}

/* ─── Bottom Navigation (Mobile) ────────────────────────── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    z-index: 1001;
    padding-bottom: env(safe-area-inset-bottom);
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
    flex: 1;
    padding: 10px 0;
}

.bottom-nav-item i {
    font-size: 18px;
}

.bottom-nav-item.active {
    color: var(--primary-light);
}

@media (max-width: 992px) {
    .bottom-nav {
        display: flex;
    }

    /* Sidebar open hone par bottom nav hide karo — upgrade plan & nav items visible rahein */
    body.sidebar-open .bottom-nav {
        display: none !important;
    }
}

/* ─── Premium Glassmorphism & Effects ──────────────────────── */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.glow-text {
    text-shadow: 0 0 15px var(--primary-glow);
}

.hover-glow {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.hover-glow:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), 0 0 15px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--primary-light) !important;
}

.hover-glow:active {
    transform: translateY(-2px);
}

/* ─── Animations ───────────────────────────────────────────── */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.animate-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}