/* ===== CSS Variables ===== */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Source+Sans+3:wght@400;600;700&display=swap');

:root {
    --bg-primary: #F5F0E8;
    --bg-secondary: #EDE5D0;
    --bg-tertiary: #FAF7F0;
    --bg-card: #FAF7F0;
    --text-primary: #2C1F0E;
    --text-secondary: #5C4A30;
    --text-muted: #9C876A;
    --text-on-accent: #FAF7F0;
    --accent-primary: #7A5C3A;
    --accent-secondary: #9C6B3A;
    --accent-gradient: #7A5C3A;
    --success: #4A7A3A;
    --success-light: rgba(74, 122, 58, 0.15);
    --warning: #A0896A;
    --warning-light: rgba(160, 137, 106, 0.15);
    --danger: #8B2E1A;
    --danger-light: rgba(139, 46, 26, 0.15);
    --border-color: #C8B89A;
    --shadow-lg: 0 4px 24px rgba(60, 40, 10, 0.18);
    --shadow-md: 0 1px 4px rgba(60, 40, 10, 0.10);
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Sans 3', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6, .section-title {
    font-family: 'Libre Baskerville', Georgia, serif;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5));
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ===== Period Selector ===== */
.period-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.period-selector label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.period-selector select {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.period-selector select:hover,
.period-selector select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

/* ===== Data Import/Export Section ===== */
.data-io-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.io-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.io-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent-secondary);
}

.io-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.io-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.io-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid;
}

.io-btn svg {
    width: 18px;
    height: 18px;
}

.io-btn.import {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.io-btn.import:hover {
    background: var(--accent-primary);
    color: var(--text-on-accent);
}

.io-btn.export {
    background: rgba(129, 140, 248, 0.1);
    color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.io-btn.export:hover {
    background: var(--accent-secondary);
    color: var(--text-on-accent);
}

.config-status {
    display: block;
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.config-status.loaded {
    color: var(--success);
    font-weight: 500;
}

/* ===== Tab Navigation ===== */
.tab-navigation {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: var(--accent-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn svg {
    width: 20px;
    height: 20px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    background: var(--accent-gradient);
    color: var(--text-on-accent);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Comparison Section ===== */
.comparison-uploads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.comparison-month {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.comparison-month h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.period-select-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.comp-period-select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
}

.upload-btn.compact {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
}

/* Comparison Table */
.comparison-table td {
    text-align: center;
}

.comparison-table td:first-child {
    text-align: left;
}

.variation-positive {
    color: var(--success) !important;
    font-weight: 600;
}

.variation-negative {
    color: var(--danger) !important;
    font-weight: 600;
}

#compVariationCard.positive {
    background: var(--success-light);
    border-color: var(--success);
}

#compVariationCard.positive .summary-value {
    color: var(--success);
}

#compVariationCard.negative {
    background: var(--danger-light);
    border-color: var(--danger);
}

#compVariationCard.negative .summary-value {
    color: var(--danger);
}

/* ===== Section Styling ===== */
section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.section-title .icon {
    width: 28px;
    height: 28px;
    color: var(--accent-primary);
}

.section-title.warning .icon {
    color: var(--warning);
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ===== Upload Section ===== */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.upload-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    border: 2px dashed var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.upload-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
}

.upload-card.loaded {
    border-color: var(--success);
    border-style: solid;
    background: var(--success-light);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
}

.upload-icon.sales {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.upload-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.upload-btn {
    background: var(--accent-gradient);
    color: var(--text-on-accent);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.upload-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.file-status {
    display: block;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-status.loaded {
    color: var(--success);
    font-weight: 500;
}

.process-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 1rem 2rem;
    background: var(--accent-gradient);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.process-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.process-btn:not(:disabled):hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
}

.process-btn svg {
    width: 24px;
    height: 24px;
}

/* ===== Uncategorized Section ===== */

/* Category Drop Zones */
.category-dropzones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    min-height: 60px;
    border: 2px dashed var(--border-color);
}

.category-dropzone {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.category-dropzone:hover {
    background: var(--accent-primary);
    color: var(--text-on-accent);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.category-dropzone.drag-over {
    background: var(--success);
    border-color: var(--success);
    color: var(--text-on-accent);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

/* Selection Controls */
.selection-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
}

.select-all-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.selection-count {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.clear-selection-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.clear-selection-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.clear-selection-btn svg {
    width: 14px;
    height: 14px;
}

/* Uncategorized List */
.uncategorized-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.uncategorized-item {
    display: grid;
    grid-template-columns: 30px 100px 1fr 120px;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    cursor: grab;
    border: 2px solid transparent;
}

.uncategorized-item.recategorize-item {
    grid-template-columns: 30px 100px 1fr auto 160px;
    cursor: pointer;
}

.uncategorized-item:hover {
    background: var(--bg-secondary);
}

.uncategorized-item.selected {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
}

.uncategorized-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.uncategorized-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.uncategorized-item .code {
    font-family: monospace;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.uncategorized-item .product {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uncategorized-item .value {
    color: var(--success);
    font-weight: 600;
    text-align: right;
    font-size: 0.9rem;
}

.category-select {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.category-select:hover,
.category-select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.apply-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
    padding: 0.875rem 1.5rem;
    background: var(--success);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.apply-btn:hover {
    background: #0ea572;
    transform: scale(1.02);
}

.apply-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== Goals Section ===== */
.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.goal-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.goal-card:hover {
    border-color: var(--accent-primary);
}

.goal-card .category-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.goal-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.goal-input {
    width: 70px;
    padding: 0.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    text-align: right;
    transition: var(--transition);
}

.goal-input:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.goal-input-wrapper span {
    color: var(--text-muted);
    font-weight: 500;
}

.save-goals-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    padding: 0.875rem 1.5rem;
    background: var(--accent-gradient);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.save-goals-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.save-goals-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== Report Section ===== */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.export-buttons {
    display: flex;
    gap: 0.75rem;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.export-btn.png {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.export-btn.png:hover {
    background: var(--success);
    color: var(--text-on-accent);
}

.export-btn.pdf {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.export-btn.pdf:hover {
    background: var(--danger);
    color: var(--text-on-accent);
}

.export-btn svg {
    width: 18px;
    height: 18px;
}

/* Export Options */
.export-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.export-options-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--accent-primary);
}

.export-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* ===== Report Container ===== */
.report-container {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    overflow: hidden;
}

.report-title {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.report-title h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.report-title p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.report-summary {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.summary-card.success {
    background: var(--success-light);
    border-color: var(--success);
}

.summary-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card.success .summary-value {
    color: var(--success);
}

/* ===== Report Table ===== */
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.report-table th {
    background: var(--bg-secondary);
    color: var(--text-on-accent);
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;

    border-bottom: 1px solid var(--accent-secondary);
}

.report-table th:first-child {
    border-radius: 8px 0 0 0;
}

.report-table th:last-child {
    border-radius: 0 8px 0 0;
}

.report-table th {

    background: var(--accent-primary);

}



.report-table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.report-table tbody tr:hover {
    background: var(--bg-primary);
}

.report-table tfoot td {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: none;
}

.report-table tfoot td:first-child {
    border-radius: 0 0 0 8px;
}

.report-table tfoot td:last-child {
    border-radius: 0 0 8px 0;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.achieved {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.not-achieved {
    background: var(--danger-light);
    color: var(--danger);
}

.status-badge svg {
    width: 14px;
    height: 14px;
}

/* Achievement Bar */
.achievement-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.achievement-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.achievement-fill.green {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.achievement-fill.yellow {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.achievement-fill.red {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.achievement-text {
    font-weight: 600;
    margin-top: 0.25rem;
    font-size: 0.85rem;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.9);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 2rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--success);
    background: var(--success-light);
}

.toast.error {
    border-color: var(--danger);
    background: var(--danger-light);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    section {
        padding: 1.5rem;
    }

    .uncategorized-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .report-header {
        flex-direction: column;
        align-items: stretch;
    }

    .export-buttons {
        justify-content: center;
    }

    .report-summary {
        flex-direction: column;
        gap: 1rem;
    }

    .report-table {
        font-size: 0.85rem;
    }

    .report-table th,
    .report-table td {
        padding: 0.5rem;
    }
}

@media print {
    body {
        background: white;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    section {
        box-shadow: none;
        border: none;
    }

    .upload-section,
    .uncategorized-section,
    .goals-section,
    .report-header,
    .export-buttons {
        display: none !important;
    }

    .report-section {
        margin: 0;
        padding: 0;
    }

    .promotions-details {
        display: none !important;
    }
}

/* ===== Promotions & Table Expansion Styles ===== */
.category-row {
    cursor: pointer;
    transition: var(--transition);
}

.category-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.category-row.expanded {
    background: rgba(99, 102, 241, 0.05);
}

.category-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chevron-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: var(--transition);
}

.expanded .chevron-icon {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.details-row {
    background: rgba(0, 0, 0, 0.15);
}

.product-details-container {
    padding: 1.5rem 2rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.product-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.product-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.product-table tr:last-child td {
    border-bottom: none;
}

.p-code {
    font-family: monospace;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.text-right {
    text-align: right !important;
}

.promo-highlight {
    color: var(--warning);
    font-weight: 600;
}

.promo-card {
    background: var(--warning-light);
    border: 1px solid var(--warning);
}

.promo-card .summary-label {
    color: var(--text-muted);
}

.promo-card .summary-value {
    color: var(--warning);
}

.upload-icon.promo {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ===== Wizard Flow ===== */
.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.wizard-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
    z-index: 2;
}

.wizard-step-indicator.active {
    color: var(--accent-primary);
}

.wizard-step-indicator.completed {
    color: var(--success);
}

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    font-weight: 600;
    transition: var(--transition);
    font-size: 1.1rem;
}

.wizard-step-indicator.active .step-circle {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.wizard-step-indicator.completed .step-circle {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.wizard-line {
    flex-grow: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 1rem;
    position: relative;
    top: -15px;
    z-index: 1;
    transition: var(--transition);
}

.wizard-line.active {
    background: var(--accent-primary);
}

.wizard-line.completed {
    background: var(--success);
}

.wizard-step {
    display: none;
    animation: fadeIn 0.4s ease;
}

.wizard-step.active {
    display: block;
}

.back-wizard-btn:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.recategorize-item .category-badge { 
    font-size: 0.8rem; 
    background: var(--bg-tertiary); 
    padding: 4px 8px; 
    border-radius: var(--radius-sm); 
    border: 1px solid var(--border-color); 
    color: var(--text-muted); 
    font-weight: 500; 
}

.recategorize-item .category-select { 
    padding: 6px 10px; 
    border-radius: var(--radius-sm); 
    border: 1px solid var(--border-color); 
    background: var(--bg-primary); 
    color: var(--text-primary); 
    outline: none; 
    font-size: 0.85rem; 
    transition: var(--transition); 
}

.recategorize-item .category-select:hover,
.recategorize-item .category-select:focus { 
    border-color: var(--accent-primary); 
}

/* ===== Profile Selector ===== */
.profile-selector {
    display: flex;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.profile-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.profile-btn.active {
    background: var(--accent-primary);
    color: var(--text-on-accent);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ===== Operator Mode (Hiding R$ Absolute Values) ===== */
/* Relatório Mensal */
.operator-mode .revenue-card,
.operator-mode .promo-card {
    display: none !important;
}

.operator-mode #reportSummarySection {
    grid-template-columns: 1fr !important;
    max-width: 400px;
    margin: 0 auto 1.5rem auto;
}

.operator-mode .report-table th:nth-child(2),
.operator-mode .report-table td:nth-child(2),
.operator-mode .report-table th:nth-child(4),
.operator-mode .report-table td:nth-child(4) {
    display: none !important;
}

.operator-mode .report-table .chevron-icon {
    display: none !important;
}

.operator-mode .category-row {
    cursor: default !important;
}

/* Comparativo de Meses */
.operator-mode .comp-m1-card,
.operator-mode .comp-m2-card {
    display: none !important;
}

.operator-mode #comparisonReportContainer .report-summary {
    grid-template-columns: 1fr !important;
    max-width: 400px;
    margin: 0 auto 1.5rem auto;
}

.operator-mode .comparison-table th:nth-child(2),
.operator-mode .comparison-table td:nth-child(2),
.operator-mode .comparison-table th:nth-child(4),
.operator-mode .comparison-table td:nth-child(4) {
    display: none !important;
}


/* ===== Auto-Save & History Toolbar ===== */
.uncategorized-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.autosave-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.autosave-badge.saved {
    color: var(--success);
}

.autosave-badge.saving {
    color: var(--warning);
}

.autosave-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    transition: background-color 0.3s;
}

.autosave-badge.saving .autosave-dot {
    background: var(--warning);
    animation: autosavePulse 1s infinite alternate;
}

@keyframes autosavePulse {
    from { opacity: 0.3; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1.15); }
}

.history-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.undo-btn, .undo-all-btn, .download-cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    text-decoration: none;
    user-select: none;
}

.undo-btn:disabled, .undo-all-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.undo-btn:not(:disabled):hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.undo-all-btn:not(:disabled):hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
    transform: translateY(-1px);
}

.download-cat-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

/* Quick Category Select inside Product card */
.quick-category-select {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    margin-left: auto;
    transition: var(--transition);
}

.quick-category-select:hover {
    border-color: var(--accent-primary);
}

/* ===== Session History Accordion ===== */
.session-history-container {
    margin-top: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.session-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    transition: background-color 0.2s;
}

.session-history-header:hover {
    background: #E5DCBF;
}

.session-history-header .history-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.session-history-content {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-empty-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    margin: 10px 0;
}

.history-cards-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-action-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition);
}

.history-action-card:hover {
    box-shadow: 0 2px 8px rgba(60, 40, 10, 0.08);
}

.history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.history-badge {
    background: var(--accent-primary);
    color: var(--text-on-accent);
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-revert-batch-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.history-revert-batch-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

.history-items-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
    font-size: 0.85rem;
    margin-top: 4px;
}

.history-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
    gap: 10px;
}

.history-item-name {
    flex: 1;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.revert-item-btn {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
    padding: 0 4px;
}

.revert-item-btn:hover {
    color: var(--danger);
}

/* Toast Actions */
.toast-content-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-undo-action-btn {
    background: var(--accent-primary);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.toast-undo-action-btn:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}
