:root {
    --primary: #1a56db;
    --primary-dark: #1342b0;
    --accent: #f59e0b;
    --bg: #f1f5f9;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

* { box-sizing: border-box; }
body { font-family: 'Nunito', sans-serif; background: var(--bg); color: var(--text); margin: 0; }

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

/* Sidebar */
#sidebar {
    width: 240px; background: var(--sidebar-bg); display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 1000; overflow-y: auto;
    transition: transform .3s;
}
.sidebar-brand { padding: 20px; border-bottom: 1px solid #1e293b; display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 1.5rem; color: var(--accent); }
.brand-name { color: #fff; font-size: 1.2rem; font-weight: 800; }
.brand-name span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 10px 0; list-style: none; margin: 0; }
.nav-section-title { font-size: .65rem; text-transform: uppercase; letter-spacing: 1.5px; color: #475569; padding: 12px 20px 4px; font-weight: 700; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 20px; color: var(--sidebar-text); text-decoration: none; font-size: .875rem; font-weight: 600; border-left: 3px solid transparent; transition: all .2s; }
.sidebar-nav .nav-link:hover { color: #e2e8f0; background: #1e293b; }
.sidebar-nav .nav-link.active { color: #fff; background: #1e3a6e; border-left-color: var(--primary); }
.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: .9rem; }
.sidebar-footer { padding: 16px; border-top: 1px solid #1e293b; }
.company-badge { display: flex; align-items: center; gap: 10px; background: #1e293b; border-radius: 8px; padding: 8px 10px; }
.company-logo-sm { width: 32px; height: 32px; border-radius: 6px; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: .85rem; overflow: hidden; flex-shrink: 0; }
.company-logo-sm img { width: 100%; height: 100%; object-fit: cover; }
.company-info { flex: 1; min-width: 0; }
.company-name-sm { color: #e2e8f0; font-size: .8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-gst-sm { color: #64748b; font-size: .68rem; }

/* Main */
#main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.topbar-title { font-size: 1.1rem; font-weight: 800; }
.content-area { padding: 24px; flex: 1; }

/* Cards */
.card { border: none; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 14px 18px; font-weight: 700; font-size: .9rem; }

/* Stat Cards */
.stat-card { border-radius: 10px; padding: 20px; color: #fff; position: relative; overflow: hidden; }
.stat-card .stat-icon { font-size: 2.2rem; opacity: .25; position: absolute; right: 16px; top: 16px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; margin-top: 4px; font-weight: 600; }
.bg-primary-g { background: linear-gradient(135deg, #1a56db, #3b82f6); }
.bg-success-g { background: linear-gradient(135deg, #059669, #10b981); }
.bg-warning-g { background: linear-gradient(135deg, #d97706, #f59e0b); }
.bg-danger-g  { background: linear-gradient(135deg, #dc2626, #ef4444); }

/* Tables */
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; background: #f8fafc; }
.table td { font-size: .875rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f0f7ff; }
.badge-status { padding: 4px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.status-paid { background: #dcfce7; color: #15803d; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }

/* Forms */
.form-label { font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.form-control, .form-select { border: 1.5px solid var(--border); font-size: .875rem; border-radius: 7px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }

/* Invoice items */
#itemsTable td input, #itemsTable td select { border: none; background: transparent; font-size: .85rem; width: 100%; outline: none; font-family: inherit; }
#itemsTable td input:focus { background: #f0f7ff; border-radius: 4px; }
#itemsTable tbody tr { border-bottom: 1px solid var(--border); }
.invoice-totals { background: #f8fafc; border-radius: 8px; padding: 16px; }
.totals-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: .875rem; }
.totals-row.grand { font-size: 1rem; font-weight: 800; border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h4 { font-weight: 800; font-size: 1.1rem; margin: 0; }

/* Print invoice */
.print-invoice { background: #fff; border-radius: 10px; padding: 36px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.inv-title { font-size: 2rem; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.inv-company-logo { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; }
.inv-logo-placeholder { width: 72px; height: 72px; border-radius: 10px; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.8rem; font-weight: 800; }
.inv-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.inv-label { font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.inv-value { font-size: .9rem; font-weight: 600; margin-top: 2px; }

/* Logo upload */
.logo-upload-area { border: 2px dashed var(--border); border-radius: 10px; padding: 28px; text-align: center; cursor: pointer; transition: all .2s; }
.logo-upload-area:hover { border-color: var(--primary); background: #f0f7ff; }

/* Search box */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 34px; }
.search-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; }

/* Chart bars */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 10px 0 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--primary); min-height: 4px; transition: height .5s; }
.bar-label { font-size: .65rem; color: var(--muted); font-weight: 700; }
.bar-val { font-size: .6rem; color: var(--primary); font-weight: 800; }

/* Toast */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.toast-msg { background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 8px; margin-bottom: 8px; font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: slideIn .3s ease; min-width: 240px; }
.toast-msg.success i { color: var(--success); }
.toast-msg.error i { color: var(--danger); }
.toast-msg.warning i { color: var(--warning); }
@keyframes slideIn { from { transform: translateX(60px); opacity:0 } to { transform: translateX(0); opacity:1 } }

/* Tabs */
.nav-pills .nav-link { font-size: .82rem; font-weight: 700; color: var(--muted); padding: 6px 16px; border-radius: 20px; }
.nav-pills .nav-link.active { background: var(--primary); color: #fff; }

/* Login page */
.login-page { min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e3a6e 100%); display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 2.5rem; color: var(--primary); }
.login-logo h2 { font-weight: 800; font-size: 1.8rem; margin-top: 8px; color: var(--text); }
.login-logo h2 span { color: var(--accent); }

.btn-primary { background: var(--primary); border-color: var(--primary); font-weight: 700; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.btn-sm { font-size: .78rem; }
.text-muted-sm { font-size: .75rem; color: var(--muted); }
.fw-800 { font-weight: 800; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

@media (max-width: 991px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.show { transform: translateX(0); }
    #main { margin-left: 0; }
}

@media print {
    #sidebar, .topbar, .no-print, .btn { display: none !important; }
    #main { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    .print-invoice { box-shadow: none !important; }
    .card { box-shadow: none !important; }
}
