:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-light: #f8fafc;
    --sidebar-bg: #1e293b;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: #1e293b;
}

/* Sidebar Styling */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    padding: 24px;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
}

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

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.sidebar h2 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: bold;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.show-sidebar-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    border: none;
    color: #94a3b8;
    width: 24px;
    height: 48px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    font-size: 12px;
    font-weight: bold;
}

.show-sidebar-btn.visible {
    opacity: 1;
    visibility: visible;
}

.show-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    width: 32px;
}

.sidebar li {
    margin-bottom: 8px;
}

.sidebar a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 1rem;
    padding: 12px 16px;
    border-radius: 8px;
    display: block;
    transition: all 0.2s;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.sidebar a:active,
.sidebar a:focus,
.sidebar a.active,
.sidebar a.current {
    background: none;
    color: #94a3b8;
    border: none;
    border-left: none;
    border-right: none;
    outline: none;
}

.sidebar a:active:hover,
.sidebar a:focus:hover,
.sidebar a.active:hover,
.sidebar a.current:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* Main Content area */
.main-content {
    margin-left: 260px;
    padding: 40px;
    width: calc(100% - 260px);
    transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out;
}

.main-content.full-width {
    margin-left: 0;
    width: 100%;
}

/* Login Styling */
/* Simplified Professional Login */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--bg-light);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    width: 400px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.login-container .company-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.login-container .tagline {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 30px;
}

.login-container h2 {
    font-size: 1.25rem;
    margin-bottom: 25px;
    color: #1e293b;
}

.login-container .form-group {
    margin-bottom: 15px;
}

.login-container input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.login-container input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
}

.error-message {
    color: var(--danger-color);
    background: #fef2f2;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.error-message.rate-limit-error {
    background: #fef3c7;
    color: var(--warning-color);
    border: 1px solid #fbbf24;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Cards & Tables */
.card {
    background: white;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    padding: 24px;
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

th {
    background: #f1f5f9;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    font-size: 0.85rem;
    text-transform: uppercase;
}

td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
}

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

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-form {
    display: flex;
    gap: 10px;
}

.search-form .form-control {
    width: 350px;
    padding: 10px 15px;
}

.search-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-btn:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}

.search-container {
    position: relative;
    width: 350px;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow: hidden;
    display: none;
    border: 1px solid #e2e8f0;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 10px;
}

.suggestion-item:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.suggestion-item i {
    color: #94a3b8;
}

/* Buttons */

.add-btn {
    background: var(--primary-color);
    color: white;
    padding: 11px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Form Controls */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #475569;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.pagination a {
    padding: 8px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    text-decoration: none;
    font-weight: 500;
}

.pagination a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.view-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #f1f5f9;
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

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

/* Global Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    margin: auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-60%);
    }

    to {
        opacity: 1;
        transform: translateY(-50%);
    }
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    border-radius: 0 0 16px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.close {
    color: #94a3b8;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #1e293b;
}

.cancel-btn {
    background: white;
    border: 1px solid #e2e8f0;
    color: #64748b;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.save-btn {
    background: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Loading Screen Styles */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 260px;
    /* Match sidebar width */
    width: calc(100% - 260px);
    /* Match main-content width */
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}


.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.loader-content p {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

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

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--sidebar-bg);
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    z-index: 1100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-header h2 {
    font-size: 1.2rem;
    color: white;
    margin: 0;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 4px;
}

.hamburger-btn span {
    width: 20px;
    height: 2px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
    }

    .sidebar.mobile-visible {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 20px 15px;
        margin-top: 60px;
    }

    .mobile-header {
        display: flex;
    }

    .show-sidebar-btn {
        display: none !important;
    }

    .loader-overlay {
        left: 0 !important;
        width: 100% !important;
    }

    .search-form .form-control,
    .search-container {
        width: 100% !important;
    }

    .header-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .login-container {
        width: 90%;
        max-width: 400px;
    }

    .receipt-meta {
        flex-direction: column;
        gap: 15px;
    }

    .meta-column.text-right {
        text-align: left;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .modal-card {
        width: 95vw !important;
        max-height: 85vh;
    }

    .billing-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 640px) {
    .card {
        padding: 15px;
        overflow-x: auto;
    }

    table {
        min-width: 600px;
        /* Force scroll on very small screens for tables */
    }

    th,
    td {
        padding: 10px;
        font-size: 0.8rem;
    }

    .add-btn {
        width: 100%;
        text-align: center;
    }
}