:root {
    --primary-color: #3B82F6; /* A modern blue */
    --primary-hover-color: #2563EB;
    --success-color: #10B981; /* A green for profit */
    --danger-color: #EF4444; /* A red for loss */
    --border-color: #D1D5DB; /* A light gray */
    --container-bg-color: #FFFFFF;
    --light-text-color: #6B7280;
    --text-color: #1F2937;
    --border-radius: 6px;
    --box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

body {
    font-family: var(--font-family-sans);
    color: var(--text-color);
    line-height: 1.6;
    background-color: #F9FAFB; /* A very light gray background */
}

.profit-loss-report-wrap h1 {
    font-size: 2em;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Filters section */
.profit-loss-report-wrap .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    background: var(--container-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
}

.profit-loss-report-wrap .filter-group {
    flex-grow: 1;
    min-width: 150px;
}

.profit-loss-report-wrap .filter-group input[type="date"],
.profit-loss-report-wrap .filter-group input[type="text"] {
    padding: 8px 12px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9em;
    box-shadow: var(--box-shadow);
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.multi-select-container, .status-filter-container {
    position: relative;
}

.product-filter-trigger, .status-filter-trigger {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    height: 40px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.9em;
}

.product-filter-dropdown, .status-filter-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 100;
    padding: 0.5rem;
    margin-top: 4px;
}

.product-filter-dropdown input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9em;
    box-shadow: var(--box-shadow);
    margin-bottom: 0.5rem;
}

.multi-select-container.is-open .product-filter-dropdown,
.status-filter-container.is-open .status-filter-dropdown {
    display: block;
}

.selected-products {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.selected-products .selected-product {
    background-color: #E5E7EB;
    color: #374151;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 0.8em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.selected-product .remove-product {
    cursor: pointer;
    font-weight: bold;
}



.profit-loss-report-wrap .filter-group input:focus,
.multi-select-container .selected-products:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

/* Buttons */
.profit-loss-report-wrap .button,
.track-button {
    padding: 0 16px;
    height: 40px;
    line-height: 38px;
    min-height: 40px;
    font-size: 0.9em;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.profit-loss-report-wrap .button.button-primary {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.profit-loss-report-wrap .button.button-primary:hover {
    background-color: var(--primary-hover-color);
    border-color: var(--primary-hover-color);
}

.profit-loss-report-wrap .button:not(.button-primary) {
    background-color: #fff;
    color: var(--text-color);
    border-color: var(--border-color);
}

.profit-loss-report-wrap .button:not(.button-primary):hover {
    background-color: #F9FAFB;
    border-color: #9CA3AF;
}

.track-button {
    display: inline-block;
    padding: 4px 12px;
    height: auto;
    line-height: normal;
    background-color: #E5E7EB;
    color: #374151;
    font-size: 0.8em;
}

.track-button:hover {
    background-color: #D1D5DB;
}

/* Stats Summary */
.stats-summary {
    margin-bottom: 1.5rem;
    font-size: 1em;
    font-weight: 500;
    background: var(--container-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stats-summary strong {
    margin: 0;
    color: var(--light-text-color);
    font-weight: 400;
}

/* Table Styles */
.table-container {
    background: var(--container-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    max-height: 75vh;
}

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

table th, table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
    font-size: 0.9em;
}

table th {
    background-color: #F9FAFB;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    text-transform: uppercase;
    font-size: 0.8em;
    color: var(--light-text-color);
}

table tbody tr:hover {
    background-color: #F3F4F6;
}

table td input.editable-field {
    width: 80px;
    padding: 6px;
    font-size: 0.9em;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    background-color: #F3F4F6;
}

table td input.editable-field:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

.profit-loss-cell.profit,
.total-profit-loss.profit,
#final-profit.profit {
    color: var(--success-color);
    font-weight: 600;
}

.profit-loss-cell.loss,
.total-profit-loss.loss,
#final-profit.loss {
    color: var(--danger-color);
    font-weight: 600;
}

.na-value {
    color: var(--light-text-color);
    font-style: italic;
}

/* Status Filter Dropdown */
.status-filter-container {
    position: relative;
}

.status-filter-trigger {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    height: 40px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.9em;
}

.status-filter-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 100;
    padding: 0.5rem;
    margin-top: 4px;
}

.status-filter-container.is-open .status-filter-dropdown {
    display: block;
}

.status-filter-dropdown label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.9em;
    border-radius: var(--border-radius);
    cursor: pointer;
}

.status-filter-dropdown label:hover {
    background-color: #F9FAFB;
}
