:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1a1d2e;
    --sidebar-hover: rgba(255, 255, 255, 0.07);
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --bg: #f4f6fb;
    --card-radius: 14px;
}

* { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

body {
    background: var(--bg);
    font-size: 0.9rem;
    color: #334155;
}

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

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.25s ease;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}

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

.brand-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-name { display: block; color: #fff; font-weight: 800; font-size: 1rem; line-height: 1.2; }
.brand-sub { display: block; color: #8b90a8; font-size: 0.7rem; letter-spacing: 0.5px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 14px; scrollbar-width: thin; }

.nav-label {
    color: #6b7090;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin: 18px 10px 8px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #a5a9c2;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s;
    text-decoration: none;
}

.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

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

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem; }

/* ===== Topbar ===== */
.topbar {
    background: #fff;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.topbar-search {
    position: relative;
}

.topbar-search i {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.topbar-search input {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 14px 8px 36px;
    width: 240px;
    background: #f8fafc;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
}

.topbar-search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }

/* ===== Content ===== */
.content-area { padding: 26px 28px; flex: 1; }

/* ===== Cards ===== */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    padding: 16px 20px;
}

.card-header h6 { font-weight: 700; color: #1e293b; }

.card-body { padding: 20px; }

/* ===== Stat cards ===== */
.stat-card {
    border-radius: var(--card-radius);
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s;
}

.stat-card:hover { transform: translateY(-3px); }

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.78rem; opacity: 0.85; font-weight: 500; }

.stat-purple { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-blue { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.stat-orange { background: linear-gradient(135deg, #f59e0b, #ea580c); }

/* ===== Buttons ===== */
.btn { border-radius: 9px; font-weight: 600; font-size: 0.85rem; padding: 8px 16px; }

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

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

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

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

.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); }

.btn-icon { padding: 6px 10px; font-size: 0.8rem; }

/* ===== Tables ===== */
.table { --bs-table-hover-bg: #f8fafc; }

.table thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 14px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

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

/* ===== Badges ===== */
.badge { font-weight: 600; padding: 5px 10px; border-radius: 20px; font-size: 0.72rem; }
.badge.bg-soft-success { background: #d1fae5; color: #065f46; }
.badge.bg-soft-danger { background: #fee2e2; color: #991b1b; }
.badge.bg-soft-warning { background: #fef3c7; color: #92400e; }
.badge.bg-soft-info { background: #e0f2fe; color: #075985; }
.badge.bg-soft-primary { background: #e0e7ff; color: #3730a3; }
.badge.bg-soft-secondary { background: #f1f5f9; color: #475569; }

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: 9px;
    border-color: #e2e8f0;
    font-size: 0.88rem;
    padding: 9px 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-label { font-weight: 600; font-size: 0.8rem; color: #475569; }

/* ===== Login page ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d2e 0%, #2d2b55 50%, #4f46e5 100%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 18px;
    padding: 40px 36px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.auth-brand {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.6rem;
    margin: 0 auto 16px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.auth-card h1 { font-size: 1.35rem; font-weight: 800; color: #1e293b; }

/* ===== Print ===== */
@media print {
    .sidebar, .topbar, .footer-area, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    body { background: #fff; }
}

/* ===== Misc ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h4 { font-weight: 800; color: #1e293b; margin: 0; }

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #94a3b8;
}

.empty-state i { font-size: 3rem; display: block; margin-bottom: 12px; opacity: 0.4; }

.invoice-print { max-width: 800px; margin: 0 auto; }
.invoice-print table { border: 1px solid #e2e8f0; }
.invoice-print .table-bordered th, .invoice-print .table-bordered td { border: 1px solid #e2e8f0; }

.pagination { margin-bottom: 0; }
.page-link { color: var(--primary); border-radius: 8px !important; margin: 0 2px; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .sidebar.show { transform: translateX(0); }
    .content-area { padding: 18px; }
}