* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Login Page Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo i {
    font-size: 3rem;
    background: linear-gradient(135deg, #000000, #333333);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #000;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.password-container {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
}

.login-btn, .register-btn, .demo-btn {
    width: 100%;
    padding: 1.25rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.login-btn {
    background: linear-gradient(135deg, #000000, #333333);
    color: white;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.register-btn, .demo-btn {
    background: rgba(255, 255, 255, 0.8);
    color: #333;
    border: 2px solid #e5e7eb;
}

.register-btn:hover, .demo-btn:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.demo-links {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.demo-btn {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.9rem;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
    margin: 1.5rem 0;
}

/* Main App Styles */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-header h2 {
    color: #000;
    font-size: 1.5rem;
    font-weight: 700;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: #000;
    color: white;
}

.nav-item i {
    width: 20px;
    margin-right: 1rem;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 0;
    transition: margin-left 0.3s ease;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.5rem;
}

#page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1f2937;
}

.user-info {
    font-weight: 500;
    color: #333;
}

/* Pages */
.page {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    margin-right: 1.5rem;
}

.stat-icon { background: #000; }
.stat-icon.pending { background: #f59e0b; }
.stat-icon.paid { background: #10b981; }
.stat-icon.overdue { background: #ef4444; }

.stat-content h3 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: #6b7280;
    font-weight: 500;
}

/* Invoice Form */
.invoice-form-container {
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.invoice-form h3 {
    color: #1f2937;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

input, textarea, select {
    padding: 1rem 1.25rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.8);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
    background: white;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Items Section */
.items-section {
    margin: 2rem 0;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    margin-bottom: 1rem;
    align-items: end;
}

.item-field {
    display: flex;
    flex-direction: column;
}

.item-field label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.item-field input, .item-field textarea {
    padding: 0.75rem;
    font-size: 0.95rem;
}

.item-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: #10b981;
    padding: 0.75rem;
}

.remove-item {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Totals */
.totals-section {
    margin-top: 2rem;
}

.total-field label {
    font-weight: 700;
    color: #10b981;
}

.total-field input {
    font-weight: 700;
    font-size: 1.2rem;
    color: #10b981;
    background: #f0fdf4;
    border-color: #34d399;
}

/* Buttons */
.btn-primary, .btn-success, .btn-secondary {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: #000;
    color: white;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 2px solid #e5e7eb;
}

.btn-primary:hover, .btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2.5rem;
}

/* Invoices List */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.search-filter {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-filter input {
    flex: 1;
    min-width: 250px;
}

.invoices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.invoice-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.invoice-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.invoice-card h3 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.invoice-card p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status.pending { background: #fef3c7; color: #92400e; }
.status.paid { background: #d1fae5; color: #065f46; }
.status.overdue { background: #fee2e2; color: #991b1b; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: #f3f4f6;
    color: #374151;
}

.invoice-preview {
    max-height: 70vh;
    overflow-y: auto;
    border: 1px solid #ccc;
    background: white;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Custom Print Styles Matching the PDF Format */
.invoice-print {
    font-family: 'Inter', sans-serif;
    padding: 3rem;
    color: #000;
    font-size: 0.95rem;
    line-height: 1.4;
    background: white;
}

.invoice-print h1, .invoice-print h2, .invoice-print h3, .invoice-print h4 {
    margin-bottom: 0.5rem;
    color: #000;
}

.invoice-print-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.header-left .logo-text h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.header-left .logo-text h1::before {
    content: "M";
    font-weight: bold;
    font-size: 3rem;
    margin-right: 10px;
    font-family: serif;
}

.header-left h3 {
    font-size: 1.1rem;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
    color: #555;
}

.business-details, .billed-to {
    margin-bottom: 1.5rem;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.meta-table {
    width: 100%;
    max-width: 300px;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.meta-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    text-align: right;
}

.invoice-summary-top {
    text-align: right;
}

.invoice-summary-top p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 3rem;
    border-bottom: 2px solid #000;
}

.items-table th {
    text-align: left;
    padding: 1rem;
    background-color: #f8f9fa;
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    font-weight: 600;
}

.items-table td {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.invoice-print-footer {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 3rem;
}

.footer-left h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.bank-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.bank-table td {
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}

.bank-table td:first-child {
    font-weight: 600;
    width: 40%;
}

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

.totals-table td {
    padding: 0.5rem;
    text-align: right;
}

.totals-table td:first-child {
    text-align: left;
}

.grand-total td {
    font-weight: 700;
    border-top: 2px solid #000;
    padding-top: 1rem;
    font-size: 1.1rem;
}

.balance-due td {
    font-weight: 700;
    background-color: #f8f9fa;
    padding: 1rem 0.5rem;
    margin-top: 0.5rem;
    display: table-cell;
}

/* Print specific styles */
@media print {
    body * {
        visibility: hidden;
    }
    #previewModal, #previewModal * {
        visibility: visible;
    }
    #previewModal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: transparent;
        padding: 0;
    }
    .modal-content {
        box-shadow: none;
        border: none;
        padding: 0;
        margin: 0;
        max-width: 100%;
    }
    .modal-header, .modal-actions {
        display: none;
    }
    .invoice-preview {
        border: none;
        max-height: none;
        overflow: visible;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .item-row { grid-template-columns: 2fr 1fr 1fr auto; }
    .form-actions { flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .login-card { padding: 2rem 1.5rem; margin: 1rem; }
    .demo-links { flex-direction: column; }
    .invoice-print-header, .invoice-print-footer { grid-template-columns: 1fr; gap: 1rem; }
    .header-right { align-items: flex-start; text-align: left; }
    .meta-table td { text-align: left; }
    .invoice-summary-top { text-align: left; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .invoices-grid { grid-template-columns: 1fr; }
}