:root {
    /* Color Palette - Light Mode */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

/* Dark Mode Variables */
.dark-mode {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --bg-main: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    transition: var(--transition);
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius);
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav li.active a,
.sidebar-nav a:hover {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    color: var(--danger);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem;
    border-radius: 8px;
    transition: var(--transition);
}

.logout-link:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    transition: var(--transition);
}

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

.top-bar-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.date-selector {
    display: flex;
    gap: 0.5rem;
}

.date-selector select {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    outline: none;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.9rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
}

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

.stat-card {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: var(--transition);
}

.stat-card:hover .stat-icon {
    transform: scale(1.1);
}

.stat-icon.revenue {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.expense {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-icon.profit {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

.stat-icon.margin {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-details h3 {
    font-size: 1.5rem;
    margin: 0.25rem 0;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-change {
    font-size: 0.75rem;
    font-weight: 600;
}

.stat-change.pos {
    color: var(--success);
}

.stat-change.neg {
    color: var(--danger);
}

.stat-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-badge.loss {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--border);
    border-radius: 3px;
    margin-top: 0.5rem;
}

.progress-bar div {
    height: 100%;
    background-color: var(--warning);
    border-radius: 3px;
    transition: width 1s ease-in-out;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.chart-card {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-height: 300px;
}

.chart-card.large {
    grid-column: span 2;
}

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

.chart-container {
    height: 220px;
    position: relative;
}

/* Insights Card */
.insights-card {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.insights-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.insight-item {
    display: flex;
    gap: 1rem;
}

.insight-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: rgba(79, 70, 229, 0.05);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.insight-text h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.insight-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Tables */
.table-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card .card-header {
    padding: 1.5rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.table-responsive {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 1rem 1.5rem;
    background-color: rgba(0, 0, 0, 0.02);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

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

.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-delete {
    color: var(--danger);
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: var(--transition);
}

.modal {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 450px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

#entry-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    outline: none;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* Reports */
.report-container {
    background-color: white;
    color: #1e293b;
    padding: 3rem;
    border-radius: var(--radius);
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--shadow);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

.report-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4f46e5;
}

.report-info {
    text-align: right;
}

.report-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.report-info p {
    color: #64748b;
    font-size: 0.9rem;
}

.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.report-stat {
    display: flex;
    flex-direction: column;
}

.report-stat span {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.report-stat strong {
    font-size: 1.25rem;
}

.report-chart h4 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.report-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }

    #printable-report,
    #printable-report * {
        visibility: visible;
    }

    #printable-report {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        box-shadow: none;
        padding: 0;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Auth messages */
.auth-message {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}

.auth-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-message.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Empty state table cell */
td.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chart-card.large {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

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

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

    .chart-card.large {
        grid-column: span 1;
    }

    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    .top-bar-right {
        gap: 0.5rem;
    }

    .report-summary-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.mobile-only {
    display: none;
}

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

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .top-bar-right {
        width: 100%;
        justify-content: space-between;
    }
}

/* Login Styles */
.login-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-card);
}

.login-auth-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    max-width: 550px;
}

.login-header {
    margin-bottom: 2.5rem;
}

.login-header h2 {
    font-size: 2rem;
    margin: 1.5rem 0 0.5rem;
}

.login-header p {
    color: var(--text-muted);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i:not(.toggle-password) {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.input-with-icon .toggle-password {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.input-with-icon .toggle-password:hover {
    color: var(--primary);
}

.input-with-icon input {
    padding-left: 2.75rem;
}

.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.forgot-password {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 0.875rem;
    font-size: 1rem;
}

.login-footer {
    margin-top: 2.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.login-visual {
    flex: 1.2;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-visual::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    top: -25%;
    left: -25%;
}

.visual-content {
    position: relative;
    z-index: 1;
    max-width: 450px;
}

.visual-content h3 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.visual-content p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.floating-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.f-stat {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
}

@media (max-width: 992px) {
    .login-visual {
        display: none;
    }

    .login-auth-card {
        max-width: 100%;
        padding: 2rem;
    }
}