:root {
    --bg-color: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --positive: #10b981;
    --negative: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 3rem;
}

.sidebar-header h2 {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.8rem;
    font-weight: 700;
}

.company-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

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

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

.sidebar-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    display: block;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    border-left: 4px solid var(--primary-color);
}

.sidebar-footer {
    margin-top: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--negative);
    cursor: pointer;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.topbar {
    margin-bottom: 3rem;
}

.topbar h1 {
    font-size: 2.2rem;
    font-weight: 600;
}

/* Glass Card */
.glass-card {
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.investments-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.loans-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.cash-icon { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.negative .cash-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }

.card-info h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.card-info .amount {
    font-size: 2rem;
    font-weight: 700;
}

.stat-card.positive .amount { color: var(--positive); }
.stat-card.negative .amount { color: var(--negative); }

/* Flow breakdown */
.cash-flow-breakdown {
    margin-top: 1.5rem;
}

.flow-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.flow-item:last-child {
    border-bottom: none;
}

.flow-item.total {
    font-size: 1.2rem;
    font-weight: 700;
}

.value.positive { color: var(--positive); }
.value.negative { color: var(--negative); }

hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

/* Forms & Crispy Forms Alignment */
.mb-3 {
    margin-bottom: 1.5rem;
    text-align: left;
}

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

.form-control, .form-select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    appearance: none; /* Removes default browser styling for select */
}

/* Custom dropdown arrow for selects */
select.form-control, select.form-select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f8fafc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select.form-control option, select.form-select option {
    background: var(--bg-color); /* Fallback for options */
    color: var(--text-primary);
}

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

/* Ensure date pickers use a dark color scheme for the native popup */
input[type="date"].form-control {
    color-scheme: dark;
}

.form-text {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.invalid-feedback {
    display: block;
    color: var(--negative);
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

ul.errorlist {
    list-style: none;
    color: var(--negative);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: left;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.glass-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.glass-table th, .glass-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.glass-table th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.glass-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

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

/* Button Styling */
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header {
        margin-bottom: 1rem;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .sidebar-header h2 {
        font-size: 1.5rem;
    }

    .company-name {
        margin-top: 0.3rem;
    }

    .sidebar-nav ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .sidebar-nav li {
        margin-bottom: 0;
    }
    
    .sidebar-nav a {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }

    .sidebar-footer {
        margin-top: 1rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .topbar {
        margin-bottom: 1.5rem;
    }
    
    .topbar h1 {
        font-size: 1.8rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .header-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem;
        margin-bottom: 1.5rem !important;
    }
    
    .header-actions > div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-actions a.btn-primary {
        text-align: center;
        margin-right: 0 !important;
    }

    .flow-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
    
    .flow-item .value {
        align-self: flex-start;
        font-size: 1.1rem;
    }
}
