/* --- VARIABLES & RESET --- */
:root {
    --bg-color: #f4f7f6;
    --bg-secondary-color: #ffffff;
    --text-color: #1f2937;
    --text-muted-color: #6b7280;
    --border-color: #e5e7eb;
    --accent-color: #2E8B57; /* Sea Green */
    --accent-hover-color: #256d45;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* --- NEW: CSS Variable for sidebar width --- */
body {
    --sidebar-width: 250px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* NEW: Minimized state */
body.sidebar-minimized {
    --sidebar-width: 80px;
}


html.dark {
    --bg-color: #111827;
    --bg-secondary-color: #1f2937;
    --text-color: #d1d5db;
    --text-muted-color: #9ca3af;
    --border-color: #374151;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
/* body rule moved up */

/* --- ICONS --- */
i.lucide, svg.lucide { /* MODIFIED: Target i OR svg */
    stroke-width: 2;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}
.title-icon {
    margin-right: 0.5rem;
}

.login-body {
    background-color: var(--bg-color);
}
.login-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}
.login-promo-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 3rem;
    background-image: linear-gradient(rgba(46, 139, 87, 0.8), rgba(37, 109, 69, 0.9)), url('https://res.cloudinary.com/dlglpfhxf/image/upload/v1762165435/Untitled_design_lan21w.png');
    background-size: cover;
    background-position: center;
    color: white;
}
.login-promo-panel h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.login-promo-panel p {
    font-size: 1.1rem;
    max-width: 400px;
    line-height: 1.6;
    opacity: 0.9;
}
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: var(--bg-color);
}
.login-card {
    background-color: var(--bg-secondary-color);
    padding: 2.5rem 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 400px;
    margin: 0;
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header img {
    height: 40px;
    margin-bottom: 0.5rem;
}
.login-header p {
    color: var(--text-muted-color);
}
.login-form .form-group {
    margin-bottom: 1.25rem;
}

.password-wrapper {
    position: relative;
}
.password-wrapper input {
    padding-right: 2.5rem !important;
}
.password-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 2.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted-color);
    display: flex;
    align-items: center;
    justify-content: center;
}
.password-toggle:hover {
    color: var(--text-color);
}

.login-hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted-color);
}

@media (max-width: 768px) {
    .login-layout {
        grid-template-columns: 1fr;
    }
    .login-promo-panel {
        display: none;
    }
    .login-form-panel {
        min-height: 100vh;
    }
}
/* --- END OF LOGIN PAGE STYLES --- */

/* --- APP LAYOUT & RESPONSIVE SIDEBAR --- */
.app-layout {
    display: flex;
}
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}
#overlay.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}
.sidebar {
    width: var(--sidebar-width); /* MODIFIED */
    background-color: var(--bg-secondary-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100%;
    z-index: 999;
    transform: translateX(calc(-1 * var(--sidebar-width)));
    transition: transform 0.3s ease, background-color 0.3s, border-color 0.3s, width 0.3s ease; /* MODIFIED */
    overflow-x: hidden; /* NEW */
}
.sidebar-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 0 1rem;
    overflow: hidden; /* NEW */
}
.sidebar-header a {
    text-decoration: none;
}
.sidebar-header img {
    height: 35px;
    margin-bottom: 0.25rem;
    transition: transform 0.3s ease; /* NEW */
}
.sidebar-header p {
    font-size: 0.8rem;
    color: var(--text-muted-color);
    transition: color 0.3s, opacity 0.3s ease; /* NEW */
    white-space: nowrap; /* NEW */
    opacity: 1; /* NEW */
}
.sidebar-nav { 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
    flex-grow: 1; 
    overflow-y: auto;
    overflow-x: hidden; /* NEW */
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
    white-space: nowrap; /* NEW */
}
.sidebar-nav a:hover {
    background-color: var(--accent-color);
    color: white;
    transform: translateX(5px);
}
.sidebar-nav a.active {
    background-color: var(--accent-color);
    color: white;
    font-weight: 600;
}
.sidebar-nav a.active i {
    color: white;
}
/* NEW: Styles for the text span inside links */
.sidebar-nav a span {
    transition: opacity 0.2s ease;
    opacity: 1;
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    transition: border-color 0.3s;
    overflow: hidden; /* NEW */
}

/* --- FIX: New wrapper for footer toggles --- */
.sidebar-footer-toggles {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.3s;
    white-space: nowrap; /* NEW */
}
/* NEW: Styles for the text span inside logout */
.logout-btn span {
    transition: opacity 0.2s ease;
    opacity: 1;
}

.main-content {
    flex-grow: 1;
    padding: 1.5rem;
    transition: margin-left 0.3s ease, width 0.3s ease; /* MODIFIED */
    width: 100%;
}
.main-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem; /* Reduced margin */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    justify-content: space-between;
}
.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.main-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
}
.page-subtitle {
    font-size: 1rem;
    color: var(--text-muted-color);
    margin-top: -0.25rem;
    margin-bottom: 1.5rem;
}
.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
}
.menu-toggle i {
    width: 24px;
    height: 24px;
}
@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
    }
    .main-content {
        margin-left: var(--sidebar-width); /* MODIFIED */
        width: calc(100% - var(--sidebar-width)); /* NEW */
    }
    .menu-toggle,
    #overlay {
        display: none;
    }
}
@media (max-width: 767.98px) {
    .sidebar.is-open {
        transform: translateX(0);
    }
    .main-content { padding: 1rem; }
    .main-header h2 { font-size: 1.5rem; }

    /* NEW: Hide the desktop-only toggle on mobile */
    #sidebar-toggle {
        display: none;
    }
}

/* --- NEW: Minimized Sidebar Styles --- */
@media (min-width: 768px) {
    body.sidebar-minimized .sidebar {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    body.sidebar-minimized .sidebar-header {
        padding: 0 0.5rem;
    }
    body.sidebar-minimized .sidebar-header img {
        transform: scale(0.9); /* Slightly shrink logo */
    }
    body.sidebar-minimized .sidebar-header p {
        opacity: 0;
        height: 0;
    }
    body.sidebar-minimized .sidebar-nav a {
        justify-content: center;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    body.sidebar-minimized .sidebar-nav a:hover {
        transform: none; /* Remove horizontal shift */
    }
    body.sidebar-minimized .sidebar-nav a span {
        opacity: 0;
        width: 0;
        overflow: hidden;
    }
    
    /* --- FIX: Adjust footer layout for minimized state --- */
    body.sidebar-minimized .sidebar-footer {
        justify-content: space-between; /* Keep this */
    }
    body.sidebar-minimized .logout-btn {
        justify-content: center;
        flex-grow: 1; /* Allow it to center */
    }
    body.sidebar-minimized .logout-btn span {
        opacity: 0;
        width: 0;
    }
    body.sidebar-minimized .sidebar-footer-toggles {
        flex-grow: 1; /* Allow them to group */
        display: flex;
        justify-content: center;
        gap: 0.5rem;
    }
    
    /* --- FIX: Rotate the icon inside the button --- */
    body.sidebar-minimized #sidebar-toggle .lucide {
        transform: rotate(180deg);
    }
}

/* --- COMPONENTS --- */
.card {
    background-color: var(--bg-secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.card h3 {
    display: flex;
    align-items: center;
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.25rem;
    font-weight: 600;
}
.grid-container {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-2-col {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.grid-3-col {
    grid-template-columns: 1fr;
}
@media (min-width: 992px) {
    .grid-3-col {
        grid-template-columns: repeat(3, 1fr);
    }
}
.grid-form {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}
@media (min-width: 992px) {
    .grid-form {
        grid-template-columns: 2fr 1fr;
    }
}
/* --- DASHBOARD GRID --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}
.dashboard-card-col-4 {
    grid-column: span 12; /* Mobile first */
}
.dashboard-card-col-6 {
    grid-column: span 12; /* Mobile first */
}
.dashboard-card-col-8 {
    grid-column: span 12; /* Mobile first */
}
.dashboard-card-full {
    grid-column: span 12;
}
@media (min-width: 768px) {
    .dashboard-card-col-4 {
        grid-column: span 6;
    }
    .dashboard-card-col-6 {
        grid-column: span 6;
    }
}
@media (min-width: 1024px) {
    .dashboard-card-col-4 {
        grid-column: span 4;
    }
    .dashboard-card-col-8 {
        grid-column: span 8;
    }
}

/* --- REDESIGNED STAT CARD --- */
.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    margin-bottom: 0; /* Handled by grid gap */
}
.stat-card h3 { /* Override card h3 */
    margin: 0;
    padding: 0;
    border: none;
    font-size: 0.9rem;
    color: var(--text-muted-color);
    font-weight: 500;
}
.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.stat-card-menu {
    color: var(--text-muted-color);
    cursor: pointer;
}
.stat-card-body {
    margin-top: 0.5rem;
}
.stat-card-body p {
    font-size: 2rem; /* Larger number */
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}
.stat-card-footer {
    margin-top: 1rem;
}
.stat-card-footer p {
    margin: 0;
    font-size: 0.85rem;
}
/* --- PROMO CARD (for dashboard) --- */
.promo-card {
    background-color: var(--accent-color);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    padding: 2rem;
}
.promo-card h3 {
    color: white;
    border: none;
    margin: 1rem 0 0.5rem 0;
    padding: 0;
}
.promo-card p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.promo-card i {
    width: 40px;
    height: 40px;
    stroke-width: 1.5;
}
.promo-card .btn-primary {
    background-color: var(--bg-secondary-color);
    color: var(--accent-color);
}
.promo-card .btn-primary:hover {
    background-color: #f0f0f0;
}

/* --- Other component styles --- */
.btn {
    display: inline-block;
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s, transform 0.1s;
    line-height: 1; /* Fix alignment */
}
.btn:hover {
    transform: translateY(-2px);
}
.btn-primary {
    background-color: var(--accent-color);
    color: white;
}
.btn-primary:hover {
    background-color: var(--accent-hover-color);
}
.btn-block {
    width: 100%;
    text-align: center;
}
.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--border-color);
}
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 6px;
}
.btn-success {
    background-color: var(--success-color);
    color: white;
}
.btn-danger {
    background-color: var(--danger-color);
    color: white;
}
.btn-icon {
    padding: 0.3rem 0.4rem;
    line-height: 1;
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-group-span-2 {
    grid-column: span 2;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle; /* Align table content */
}
th {
    font-weight: 600;
    background-color: var(--bg-color);
}
.table-responsive {
    overflow-x: auto;
}
.status-badge {
    padding: 0.2em 0.6em;
    border-radius: 1em;
    font-size: 0.8rem;
    color: white;
    font-weight: 600;
}
.status-paid,
.status-received,
.status-income {
    background-color: var(--success-color);
}
.status-unpaid,
.status-pending,
.status-payment,
.status-expense {
    background-color: var(--danger-color);
}
.status-payment {
    background-color: #f59e0b; /* Orange */
}
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}
.text-success {
    color: var(--success-color);
}
.text-danger {
    color: var(--danger-color);
}
.text-bold {
    font-weight: 600;
}
.text-muted {
    color: var(--text-muted-color);
}
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted-color);
}
.icon-moon {
    display: none;
}
.icon-sun {
    display: block;
}
html.dark .icon-moon {
    display: block;
}
html.dark .icon-sun {
    display: none;
}
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

/* --- CALCULATION PREVIEW --- */
.calculation-preview {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.calc-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}
.calc-label i {
    color: var(--accent-color);
    width: 16px;
    height: 16px;
}
.calc-label-muted {
    color: var(--text-muted-color);
    font-size: 0.9rem;
    font-weight: 400;
}
.calc-label-muted i {
    color: var(--text-muted-color);
}
.calc-value {
    font-weight: 600;
    font-size: 1.05rem;
}
.calc-value-muted {
    font-size: 0.9rem;
    color: var(--text-muted-color);
}
.calc-row.emphasis .calc-value {
    color: var(--accent-color);
    font-size: 1.2rem;
}
.calc-hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.5rem 0;
}
.calc-total {
    background-color: var(--accent-color);
    color: white;
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.calc-total .calc-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}
.calc-total .calc-value {
    font-size: 1.5rem;
    font-weight: 700;
}
/* --- --- */

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}
.chart-container-pie {
    position: relative;
    height: 300px;
    max-width: 300px;
    margin: auto;
}
.no-data-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    color: var(--text-muted-color);
    text-align: center;
}
.no-data-message i {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    stroke-width: 1.5;
}
.no-data-message p {
    font-size: 1.1rem;
    font-weight: 500;
}
/* --- TOAST NOTIFICATIONS & ALERTS --- */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 100px);
    background-color: var(--accent-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    font-weight: 600;
}
.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}
.alert-card {
    background-color: #fffbe6;
    border: 1px solid #fde68a;
    color: #a16207;
    margin-bottom: 0; /* Handled by grid */
}
html.dark .alert-card {
    background-color: #4a3300;
    border-color: #785501;
    color: #fde047;
}
.alert-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.alert-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.alert-list li+li {
    border-top: 1px solid var(--border-color);
}
.alert-list i {
    color: #facc15;
}

/* --- PROFILE PAGE --- */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (min-width: 768px) {
    .profile-header {
        flex-direction: row;
        text-align: left;
    }
}
.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 600;
    object-fit: cover; /* This makes the image cover the area, not stretch */
    border: 3px solid var(--bg-secondary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.profile-name h2 {
    font-size: 2rem;
    margin: 0;
}
.profile-name p {
    color: var(--text-muted-color);
}
/* --- FORM RADIO TOGGLE (Still used in settings) --- */
.radio-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.radio-group input[type="radio"] {
    display: none;
}
.radio-group label {
    flex: 1;
    text-align: center;
    padding: 0.75rem;
    cursor: pointer;
    color: var(--text-muted-color);
    background-color: var(--bg-color);
    transition: background-color 0.2s, color 0.2s;
    font-weight: 500;
}
.radio-group label:not(:last-child) {
    border-right: 1px solid var(--border-color);
}
.radio-group input[type="radio"]:checked+label {
    background-color: var(--accent-color);
    color: white;
}

/* --- FOOTER LINK --- */
.footer-link {
    color: var(--accent-color);
    text-decoration: none; /* No underline by default */
    font-weight: 600;
    position: relative;
    padding-bottom: 2px;
    transition: color 0.3s ease;
}
.footer-link:hover {
    color: var(--accent-hover-color); /* Darken color on hover */
}
/* Animated underline effect */
.footer-link::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--accent-hover-color);
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
}
.footer-link:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* --- HEADER NOTIFICATIONS --- */
.notifications-wrapper {
    position: relative;
}
.notifications-toggle {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    color: var(--text-muted-color);
}
.notifications-toggle:hover {
    color: var(--text-color);
}
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--bg-secondary-color);
}
.notifications-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    background-color: var(--bg-secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
}
.notifications-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.notifications-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.notifications-header h3 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1rem;
    font-weight: 600;
}
.notification-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--text-color);
    text-decoration: none;
}
.notification-item:not(.empty) {
    transition: background-color 0.2s;
}
.notification-item:not(.empty):hover {
    background-color: var(--bg-color);
}
.notification-item + .notification-item {
    border-top: 1px solid var(--border-color);
}
.notification-item.empty {
    color: var(--text-muted-color);
    justify-content: center;
}
.notification-item i {
    flex-shrink: 0;
    color: var(--accent-color);
}

/* --- CALENDAR STYLES --- */
.fc-event {
    cursor: pointer;
    border: none !important;
    padding: 4px 6px;
}
.fc-event-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}
.fc-event-title .lucide {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}
.fc-daygrid-day.fc-day-today {
    background-color: rgba(46, 139, 87, 0.1);
}
html.dark .fc-daygrid-day.fc-day-today {
     background-color: rgba(46, 139, 87, 0.2);
}

/* --- CALENDAR RESPONSIVE FIX --- */
@media (max-width: 576px) {
    .fc-header-toolbar {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }
    .fc-header-toolbar .fc-toolbar-chunk {
        display: flex;
        align-items: center;
    }
}

/* --- Dynamic Sack Form Styles --- */
#sacks-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.sack-entry-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
}
html.dark .sack-entry-card {
    background-color: #111827; /* Darker bg for contrast */
}
.sack-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.sack-entry-header h4 {
    margin: 0;
    font-weight: 600;
}
.sack-net-display {
    font-weight: 600;
    color: var(--accent-color);
}
.sack-net-display span {
    font-size: 1.1rem;
}
.remove-sack-btn {
    padding: 0.25rem !important; /* Override .btn */
    line-height: 1;
}
.remove-sack-btn i {
    width: 16px;
    height: 16px;
}
.sack-entry-body {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.sack-entry-body .form-group {
    margin-bottom: 0; /* Handled by grid gap */
}
.sack-entry-body .form-group label {
    font-size: 0.85rem;
    font-weight: 400;
}
.sack-entry-body .form-group input,
.sack-entry-body .form-group select {
    padding: 0.6rem;
    font-size: 0.95rem;
}
#add-sack-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: -0.5rem;
}

/* --- Responsive adjustment for sack entry --- */
@media (max-width: 480px) {
    .sack-entry-body {
        grid-template-columns: 1fr; /* Stack on small screens */
    }
}

/* --- Action Buttons Styling --- */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.action-buttons form {
    margin: 0; /* Remove default form margin */
    display: inline-flex; /* Make form align correctly */
}

/* --- NEW: REPORT PAGE STYLES --- */
.report-filter-card .filter-form {
    flex-direction: column;
    align-items: stretch;
}
.filter-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted-color);
    margin: 1.5rem 0;
}
.filter-divider::before, .filter-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}
.filter-divider span {
    padding: 0 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.report-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.report-actions p {
    margin: 0;
    color: var(--text-muted-color);
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-muted-color);
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transform: translateY(2px);
    white-space: nowrap;
}
.tab-link:hover {
    color: var(--text-color);
}
.tab-link.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}
.tab-link i {
    width: 16px;
    height: 16px;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

.report-table-footer td,
.report-table-footer strong {
    font-weight: 700;
    font-size: 1.05rem;
    border-top: 2px solid var(--text-color);
    color: var(--text-color);
}
html.dark .report-table-footer td,
html.dark .report-table-footer strong {
    border-top-color: var(--text-color);
}

/* --- NEW: PRINT STYLES FOR REPORTS --- */
.report-print-header {
    display: none; /* Hide by default */
}
@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
    .sidebar,
    .main-header,
    .report-filter-card,
    .report-actions,
    .main-footer,
    .filter-form,
    .theme-toggle,
    .logout-btn,
    .tabs {
        display: none !important;
    }
    .app-layout {
        display: block !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid !important;
    }
    
    /* --- THE FIX: Force stacking on print --- */
    .dashboard-grid {
        display: block !important;
    }
    .dashboard-card-col-4,
    .dashboard-card-col-6,
    .dashboard-card-col-8,
    .dashboard-card-full {
        grid-column: auto !important;
        width: 100% !important;
        display: block !important;
        float: none !important;
        page-break-inside: avoid !important;
    }
    /* --- End Fix --- */
    
    .chart-container, .chart-container-pie {
        height: 300px !important; /* Fix chart height for printing */
        page-break-inside: avoid !important;
    }
    h3, h4 {
        page-break-after: avoid !important;
    }
    table {
        page-break-inside: auto !important;
    }
    tr {
        page-break-inside: avoid !important;
    }
    
    /* Show print-specific elements */
    .report-print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        padding: 1.5rem;
        border-bottom: 2px solid #2E8B57;
        margin-bottom: 2rem;
    }
    .report-logo h1 {
        color: #2E8B57 !important;
        margin: 0;
        font-size: 2rem;
    }
    .report-logo p {
        margin: 0;
        font-size: 1.1rem;
    }
    .report-details {
        text-align: right;
        font-size: 1rem;
    }

    .report-content {
        margin-top: 1rem;
    }
    .tab-content,
    .tab-content.active {
        display: block !important; /* Show all tab content */
    }
    .report-page {
        page-break-before: always; /* Each tab starts on a new page */
    }
    .report-page:first-child {
        page-break-before: auto; /* Not before the first one */
    }
    .no-print {
        display: none !important;
    }
    
    /* Tweak print table colors */
    .text-success { color: #22c55e !important; }
    .text-danger { color: #ef4444 !important; }
    .status-badge {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !imporant;
        border: 1px solid #999;
    }
    .report-table-footer td,
    .report-table-footer strong {
        border-top: 2px solid #333 !important;
        color: #000 !important;
    }
    .stat-card-body p {
        color: #000 !important;
    }
}
@media (max-width: 480px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group-span-2 {
        grid-column: span 1;
    }
    .main-content { padding: 0.5rem; }
    .card { padding: 1rem; }
    .card h3 {
        margin: -1rem -1rem 1rem -1rem;
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
    }
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .report-filter-card .filter-form {
        flex-direction: row; /* Overrride for this card */
        flex-wrap: wrap;
    }
}

/* --- NEW: AI INSIGHTS PAGE --- */
.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--border-color);
    border-bottom-color: var(--accent-color);
    border-radius: 50%;
    display: block;
    margin: 2rem auto;
    animation: rotation 1s linear infinite;
}

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

.gemini-response-content {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    line-height: 1.7;
}

/* Basic markdown formatting for response */
.gemini-response-content h1,
.gemini-response-content h2,
.gemini-response-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}
.gemini-response-content h1 { font-size: 1.5rem; }
.gemini-response-content h2 { font-size: 1.25rem; }
.gemini-response-content h3 { font-size: 1.1rem; }

.gemini-response-content p {
    margin-bottom: 1rem;
}

.gemini-response-content ul,
.gemini-response-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.gemini-response-content li {
    margin-bottom: 0.5rem;
}

.gemini-response-content strong,
.gemini-response-content b {
    font-weight: 600;
}

.gemini-response-content code {
    background-color: var(--border-color);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: monospace;
}

.gemini-response-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    margin-left: 0;
    font-style: italic;
    color: var(--text-muted-color);
}


/* --- AI CHAT INTERFACE --- */
.chat-card {
    display: flex;
    flex-direction: column;
    /* Allow chat to fill height - you may need to adjust */
    height: calc(100vh - 160px); 
    padding: 0;
    margin-bottom: 0;
}
.chat-card h3 {
    padding: 1rem 1.5rem;
    margin: 0;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}
.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.chat-message {
    display: flex;
    gap: 1rem;
    max-width: 90%;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-avatar i {
    width: 20px;
    height: 20px;
    color: var(--text-muted-color);
}
.chat-bubble {
    background-color: var(--bg-color);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    line-height: 1.7;
}

/* User Message */
.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-message.user .chat-avatar {
    background-color: var(--accent-color);
}
.chat-message.user .chat-avatar i {
    color: white;
}
.chat-message.user .chat-bubble {
    background-color: var(--accent-color);
    color: white;
}

/* Bot Message */
.chat-message.bot .chat-avatar {
    background-color: var(--bg-secondary-color);
    border: 1px solid var(--border-color);
}
.chat-message.bot .chat-avatar i {
    color: var(--accent-color);
}
.chat-message.bot .chat-bubble {
    background-color: var(--bg-secondary-color);
    border: 1px solid var(--border-color);
}

/* Error Message */
.chat-message.bot.error .chat-bubble {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
html.dark .chat-message.bot.error .chat-bubble {
    background-color: #4a1c20;
    color: #f8d7da;
    border: 1px solid #721c24;
}

/* Bot Message Content Formatting */
.chat-bubble p { margin-bottom: 1rem; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol {
    margin-left: 1.25rem;
    margin-bottom: 1rem;
}
.chat-bubble li { margin-bottom: 0.5rem; }
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.chat-bubble blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--text-muted-color);
}

/* Spinner inside chat */
.chat-message.bot .spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
    margin: 0.5rem auto;
    animation: rotation 0.8s linear infinite;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary-color);
    flex-shrink: 0;
}
.chat-input-area input {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}
.chat-input-area .btn {
    padding: 0.75rem;
}
.chat-input-area .btn i {
    width: 20px;
    height: 20px;
}
@media (max-width: 767.98px) {
    .chat-card {
        height: calc(100vh - 140px);
    }
}