/* Profitability Dashboard Styles - v2.0 Enhanced */

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #faf8f5 100%);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius, 0.75rem);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.04);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-main, #141414);
    margin-bottom: 0.125rem;
}

.page-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted, #6b7280);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.last-update {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    background: #f3f4f6;
    border-radius: 20px;
}

/* ============================================
   SIMULATION BANNER
   ============================================ */
.simulation-banner {
    background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
    border: 1px solid #fdba74;
    color: #c2410c;
    padding: 0.875rem 1rem;
    border-radius: var(--radius, 0.75rem);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.85rem;
}

.profitability-alerts {
    margin-bottom: 2rem;
}

.profitability-alert-card {
    background-color: var(--mm-error-bg);
    border: 1px solid var(--mm-error);
    border-radius: var(--mm-radius-lg);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.profitability-alert-icon {
    color: var(--mm-error);
    font-size: 1.5rem;
    margin-top: 0.25rem;
}

.profitability-alert-title {
    color: var(--mm-text);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.profitability-alert-text {
    color: var(--mm-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.profitability-alert-list {
    color: var(--mm-text-secondary);
    font-size: 0.85rem;
    padding-left: 1.5rem;
}

/* ============================================
   TABS NAVIGATION
   ============================================ */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    padding-bottom: 1px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--primary, #EC7014);
}

.tab-btn.active {
    color: var(--primary, #EC7014);
    border-bottom-color: var(--primary, #EC7014);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   FILTERS
   ============================================ */
.filters {
    margin-bottom: 1.5rem;
}

.profitability-analysis-filters {
    margin-bottom: 1.5rem;
}

.profitability-analysis-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.profitability-date-range {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.profitability-date-input {
    width: 100%;
    min-width: 0;
}

.profitability-filter-action {
    display: flex;
    align-items: flex-end;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.875rem;
    background: var(--surface, #fff);
    padding: 1.25rem;
    border-radius: var(--radius, 0.75rem);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-group label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted, #6b7280);
    letter-spacing: 0.05em;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select, 
.search-wrapper input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius-sm, 0.375rem);
    background-color: var(--surface, #fff);
    color: var(--text-main, #141414);
    font-size: 0.8125rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-wrapper select:focus, 
.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary, #EC7014);
    box-shadow: 0 0 0 3px rgba(236, 112, 20, 0.1);
}

/* Date Presets */
.date-presets {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.date-presets button:not(.mm-btn),
.btn-xs {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.15s;
    cursor: pointer;
    white-space: nowrap;
}

.date-presets button:not(.mm-btn):hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.date-presets .mm-btn {
    white-space: nowrap;
}

/* ============================================
   KPI CARDS - ENHANCED
   ============================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface, #fff);
    padding: 1.125rem;
    border-radius: var(--radius, 0.75rem);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    opacity: 0;
    transition: opacity 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-icon-wrapper {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-icon-wrapper.revenue { background: #d1fae5; color: #10b981; }
.kpi-icon-wrapper.orders { background: #fde2cf; color: #EC7014; }
.kpi-icon-wrapper.ticket { background: #fef3c7; color: #f59e0b; }
.kpi-icon-wrapper.campaigns { background: #fee2e2; color: #ef4444; }
.kpi-icon-wrapper.refunds { background: #fee2e2; color: #ef4444; }

.kpi-card:has(.kpi-icon-wrapper.revenue)::before { background: #10b981; }
.kpi-card:has(.kpi-icon-wrapper.orders)::before { background: #EC7014; }
.kpi-card:has(.kpi-icon-wrapper.ticket)::before { background: #f59e0b; }
.kpi-card:has(.kpi-icon-wrapper.campaigns)::before { background: #ef4444; }
.kpi-card:has(.kpi-icon-wrapper.refunds)::before { background: #ef4444; }

.profitability-bulk-highlight {
    background: var(--mm-bg-secondary);
    color: var(--mm-text-primary);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--mm-border);
}

.profitability-bulk-highlight-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.profitability-bulk-highlight-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profitability-bulk-highlight-icon {
    font-size: 1.5rem;
    color: var(--mm-accent);
}

.profitability-bulk-highlight-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.profitability-bulk-highlight-subtitle {
    font-size: 0.875rem;
    color: var(--mm-text-secondary);
}

.profitability-bulk-highlight-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.kpi-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main, #141414);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.kpi-change {
    font-size: 0.6875rem;
    font-weight: 600;
    margin-top: 0.125rem;
}

.kpi-change.positive { color: #10b981; }
.kpi-change.negative { color: #ef4444; }

/* ============================================
   CHARTS
   ============================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--surface, #fff);
    padding: 1.25rem;
    border-radius: var(--radius, 0.75rem);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.chart-card-wide {
    grid-column: 1 / -1;
}

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

.chart-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main, #141414);
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.chart-card-wide .chart-container {
    height: 350px;
}

/* ============================================
   TABLES
   ============================================ */
.table-card {
    background: var(--surface, #fff);
    border-radius: var(--radius, 0.75rem);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: #fff;
    z-index: 10;
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main, #141414);
}

.table-container {
    overflow-x: auto;
    max-height: 500px;
    position: relative;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
}

th {
    background: var(--background, #F8F3EB);
    padding: 0.625rem 0.875rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border, #e5e7eb);
    white-space: nowrap;
}

td {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    color: var(--text-main, #141414);
    vertical-align: middle;
}

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

tbody tr {
    transition: background 0.15s;
}

tbody tr:hover {
    background: #faf8f5;
}

/* Sticky Columns */
th.sticky-col, td.sticky-col {
    position: sticky;
    left: 0;
    background: var(--surface, #fff);
    z-index: 15;
}

th.sticky-col {
    z-index: 25;
    background: var(--background, #F8F3EB);
}

th.sticky-col-2, td.sticky-col-2 {
    position: sticky;
    left: 40px;
    background: var(--surface, #fff);
    z-index: 15;
    border-right: 1px solid var(--border, #e5e7eb);
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.08);
}

th.sticky-col-2 {
    z-index: 25;
    background: var(--background, #F8F3EB);
}

tbody tr:hover td.sticky-col,
tbody tr:hover td.sticky-col-2 {
    background: #faf8f5;
}

/* ============================================
   COLUMN WIDTHS
   ============================================ */
.col-checkbox { width: 40px; text-align: center; }
.col-product { min-width: 200px; max-width: 350px; }
.col-status { width: 80px; }
.col-section { width: 100px; }
.col-money { width: 90px; text-align: right; }
.col-margin { width: 100px; }
.col-qty { width: 70px; text-align: center; }
.col-actions { width: 140px; text-align: right; }

/* ============================================
   CELL CONTENT LAYOUTS
   ============================================ */
.product-cell {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.product-title {
    font-weight: 500;
    color: var(--text-main, #141414);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
}

.product-variant {
    font-size: 0.6875rem;
    color: var(--text-muted, #6b7280);
}

.margin-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.margin-value {
    font-size: 0.75rem;
    font-weight: 600;
}

.qty-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.refund-badge {
    font-size: 0.625rem;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 2px 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.actions-cell {
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
    align-items: center;
}

.profitability-bulk-bar {
    background: var(--bg-card);
    border: 1px solid var(--primary-color);
    padding: 0.75rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.profitability-bulk-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profitability-bulk-count {
    font-weight: 600;
    color: var(--primary-color);
}

.profitability-margin-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.profitability-margin-modal-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1rem;
    width: 400px;
    max-width: 90%;
}

.profitability-margin-modal-title {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.profitability-margin-modal-section {
    margin-bottom: 1rem;
}

.profitability-margin-modal-section-lg {
    margin-bottom: 1.5rem;
}

.profitability-margin-modal-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
    margin-bottom: 0.25rem;
}

.profitability-margin-modal-label-strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.profitability-margin-modal-value {
    font-weight: 500;
}

.profitability-margin-modal-strong {
    font-weight: 600;
}

.profitability-margin-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profitability-margin-modal-row {
    display: flex;
    gap: 0.5rem;
}

.profitability-margin-modal-input {
    flex: 1;
}

.profitability-margin-modal-preview {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    font-weight: 600;
}

.profitability-margin-modal-helper {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    margin-top: 0.5rem;
}

.profitability-margin-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, #e5e7eb);
}

.profitability-product-title {
    font-weight: 500;
}

.profitability-product-variant {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

.profitability-margin-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.profitability-margin-value {
    font-size: 0.8rem;
    font-weight: 600;
}

.profitability-quantity-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profitability-quantity-value {
    font-weight: 500;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.btn-action {
    border: none;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    font-size: 0.75rem;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-margin { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.btn-price { background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); color: white; }
.btn-cost { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; }
.btn-shopify { background: #f3f4f6; border: 1px solid #d1d5db; color: #4b5563; }

/* ============================================
   MARGIN BADGES
   ============================================ */
.margin-badge {
    padding: 0.1875rem 0.625rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.6875rem;
    display: inline-block;
}
.margin-critical { background-color: #fee2e2; color: #991b1b; }
.margin-attention { background-color: #fef3c7; color: #92400e; }
.margin-good { background-color: #d1fae5; color: #065f46; }
.margin-great { background-color: #dbeafe; color: #1e40af; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.profitability-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(1rem);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 400px;
}

.profitability-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.profitability-toast-success { background: #059669; }
.profitability-toast-error { background: #dc2626; }
.profitability-toast-warning { background: #d97706; }
.profitability-toast-info { background: #4f46e5; }

/* ============================================
   FILTER CHIPS
   ============================================ */
.profitability-filter-chips {
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0;
}

.profitability-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.75rem;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #c7d2fe;
}

.profitability-chip-remove {
    background: none;
    border: none;
    color: #6366f1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 0.625rem;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.profitability-chip-remove:hover {
    opacity: 1;
}

/* ============================================
   PAGINATION
   ============================================ */
.profitability-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--surface, #fff);
}

.profitability-pagination-info {
    font-size: 0.8125rem;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
    padding: 0 0.5rem;
    min-width: 110px;
    text-align: center;
}

/* ============================================
   TABLE CONTROLS & RESULTS COUNT
   ============================================ */
.profitability-table-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profitability-per-page-label select {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    background: var(--surface, #fff);
    color: var(--text-main, #141414);
}

.profitability-results-count {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
    white-space: nowrap;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.profitability-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted, #6b7280);
}

.profitability-empty-state i {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.profitability-empty-state h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main, #141414);
    margin-bottom: 0.5rem;
}

.profitability-empty-state p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ============================================
   TOTALS ROW
   ============================================ */
.profitability-totals-row {
    background: var(--background, #f8f3eb) !important;
    border-top: 2px solid var(--primary, #EC7014);
    font-weight: 600;
}

.profitability-totals-row td {
    padding: 0.75rem 0.875rem;
    font-size: 0.8125rem;
}

/* ============================================
   TREND INDICATORS
   ============================================ */
.profitability-trend-up {
    color: #10b981;
    font-size: 0.625rem;
    margin-left: 0.25rem;
}

.profitability-trend-down {
    color: #ef4444;
    font-size: 0.625rem;
    margin-left: 0.25rem;
}

/* ============================================
   NO COST FLAG
   ============================================ */
.profitability-no-cost-flag {
    color: #f59e0b;
    font-size: 0.875rem;
    margin-right: 0.25rem;
    cursor: help;
}

/* ============================================
   SELECTED ROW
   ============================================ */
.selected-row {
    background: #eef2ff !important;
}

.selected-row td.sticky-col,
.selected-row td.sticky-col-2 {
    background: #eef2ff !important;
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.profitability-margin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

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

.profitability-margin-modal-header .profitability-margin-modal-title {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profitability-margin-modal-card {
    position: relative;
    z-index: 1;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablets and below */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 250px;
    }
    
    .chart-card-wide .chart-container {
        height: 300px;
    }
}

/* Mobile landscape */
@media (max-width: 768px) {
    .page-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .filters-grid {
        grid-template-columns: 1fr 1fr;
        padding: 1rem;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .kpi-card {
        padding: 0.875rem;
    }
    
    .kpi-icon-wrapper {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }
    
    .kpi-value {
        font-size: 1.125rem;
    }
    
    .kpi-label {
        font-size: 0.6875rem;
    }
    
    .table-header {
        padding: 0.875rem 1rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .table-container {
        max-height: 400px;
    }
    
    th, td {
        padding: 0.5rem 0.625rem;
        font-size: 0.75rem;
    }
    
    .date-presets {
        width: 100%;
    }
    
    .date-presets button {
        flex: 1;
        min-width: 0;
        padding: 0.5rem 0.375rem;
        font-size: 0.6875rem;
    }
    
    .charts-grid {
        gap: 0.75rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
    
    .chart-container {
        height: 220px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.125rem;
    }
    
    .page-subtitle {
        font-size: 0.75rem;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 0.625rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    .kpi-card {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .kpi-icon-wrapper {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
        border-radius: 8px;
    }
    
    .kpi-value {
        font-size: 1rem;
    }
    
    .kpi-change {
        font-size: 0.625rem;
    }
    
    .simulation-banner {
        padding: 0.75rem;
        font-size: 0.75rem;
        flex-wrap: wrap;
    }
    
    .chart-header h3 {
        font-size: 0.875rem;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .table-container {
        max-height: 350px;
    }
    
    .col-product {
        min-width: 150px;
    }
    
    .btn-action {
        padding: 0.25rem 0.375rem;
        font-size: 0.6875rem;
    }
    
    .margin-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.5rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-card {
        flex-direction: row;
        justify-content: flex-start;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'SF Mono', 'Monaco', monospace; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
