/* Modern Reconciliation Tool CSS */

/* ===== CORE DESIGN SYSTEM ===== */
:root {
  /* Color Palette */
  --color-primary: #3b82f6; /* Blue 500 */
  --color-primary-light: #60a5fa; /* Blue 400 */
  --color-primary-dark: #2563eb; /* Blue 600 */
  --color-secondary: #6366f1; /* Indigo 500 */
  --color-success: #10b981; /* Emerald 500 */
  --color-warning: #f59e0b; /* Amber 500 */
  --color-danger: #ef4444; /* Red 500 */
  --color-info: #64748b; /* Slate 500 */

  /* Background Colors */
  --bg-page: #f8fafc; /* Slate 50 */
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa; /* Slightly off-white */
  --bg-muted: #f1f5f9; /* Slate 100 */
  --bg-subtle: #f8fafc; /* Slate 50 (same as page) */

  /* Text Colors */
  --text-primary: #1e293b; /* Slate 800 */
  --text-secondary: #475569; /* Slate 600 */
  --text-muted: #64748b; /* Slate 500 */
  --text-light: #94a3b8; /* Slate 400 */
  --text-white: #ffffff;

  /* Border Colors */
  --border-light: #e2e8f0; /* Slate 200 */
  --border-medium: #cbd5e1; /* Slate 300 */
  --border-focus: var(--color-primary-light); /* Blue 400 */

  /* Status Colors (Reiterate for clarity) */
  --status-positive: var(--color-success);
  --status-negative: var(--color-danger);
  --status-neutral: var(--color-info);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Spacing (Using 0.25rem increments) */
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem;  /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem;    /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem;  /* 24px */
  --space-8: 2rem;    /* 32px */
  --space-10: 2.5rem; /* 40px */
  --space-12: 3rem;   /* 48px */
  --space-16: 4rem;   /* 64px */

  /* Border Radius */
  --radius-sm: 0.25rem; /* 4px */
  --radius-md: 0.375rem;/* 6px */
  --radius-lg: 0.5rem;  /* 8px */
  --radius-xl: 0.75rem; /* 12px */
  --radius-2xl: 1rem;   /* 16px */
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  /* Z-index layers */
  --z-base: 1;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-fixed: 30;
  --z-modal-backdrop: 40;
  --z-modal: 50;
  --z-tooltip: 60;
}

/* ===== BASE STYLES ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== LAYOUT ===== */
.results-container {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding: var(--space-6) var(--space-4); /* Responsive padding */
}

.results-header {
  margin-bottom: var(--space-8);
  display: flex;
  flex-wrap: wrap; /* Allow wrapping on small screens */
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.header-meta {
  text-align: right;
  flex-shrink: 0; /* Prevent shrinking */
}

.header-meta h1 {
  font-size: 1.75rem; /* Slightly larger */
  font-weight: 700; /* Bolder */
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}
.header-meta span {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
    display: block;
}

/* ===== BACK BUTTON ===== */
.back-button {
  display: inline-flex; /* Changed from flex to inline-flex */
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: none;
  border: 1px solid transparent; /* Add border for focus */
  border-radius: var(--radius-md);
  color: var(--color-primary);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
  white-space: nowrap;
}

.back-button:hover {
  background-color: rgba(59, 130, 246, 0.1); /* Subtle hover background */
  color: var(--color-primary-dark);
}
.back-button:focus-visible {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3);
}

.back-button svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 2.5; /* Slightly thicker */
}

/* ===== SUMMARY CARDS ===== */
.summary-cards {
  display: grid;
  /* More responsive grid */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg); /* Slightly less rounded */
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-light); /* Subtle border */
}

.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* Indicator styles using border */
.summary-card.positive {
  border-left: 4px solid var(--status-positive);
}
.summary-card.negative {
  border-left: 4px solid var(--status-negative);
}
/* Remove gradient background unless specifically desired */
/* .summary-card.positive { background: linear-gradient(...); } */
/* .summary-card.negative { background: linear-gradient(...); } */

.card-icon {
  margin-bottom: var(--space-3);
  color: var(--color-primary);
  display: inline-flex; /* Keeps icon size based on content */
  padding: var(--space-2);
  background: rgba(59, 130, 246, 0.1); /* Primary color subtle background */
  border-radius: var(--radius-md);
}

.summary-card.positive .card-icon {
  color: var(--status-positive);
  background: rgba(16, 185, 129, 0.1);
}

.summary-card.negative .card-icon {
  color: var(--status-negative);
  background: rgba(239, 68, 68, 0.1);
}

.card-content h3 {
  color: var(--text-secondary);
  font-size: 0.8rem; /* Slightly smaller */
  font-weight: 600; /* Slightly bolder */
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-value {
  font-size: 1.875rem; /* Larger */
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: var(--space-1);
  display: block; /* Ensure block display */
}
/* Apply status colors to the value itself */
.card-value.positive { color: var(--status-positive); }
.card-value.negative { color: var(--status-negative); }

.impact-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted); /* Default muted color */
  display: block; /* Ensure block display */
}
/* Apply status colors to the label if needed (e.g., for Net Adjustment) */
.impact-label.positive { color: var(--status-positive); }
.impact-label.negative { color: var(--status-negative); }

/* ===== TAB NAVIGATION ===== */
.tab-navigation {
  margin-bottom: var(--space-8);
  border-bottom: 1px solid var(--border-medium); /* Slightly darker border */
  display: flex;
  gap: var(--space-1); /* Reduced gap */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  padding-bottom: 0; /* Remove padding-bottom */
}
.tab-navigation::-webkit-scrollbar { display: none; }

.tab-button {
  padding: var(--space-3) var(--space-5); /* Adjust padding */
  background: none;
  border: none;
  border-bottom: 3px solid transparent; /* Thicker indicator */
  margin-bottom: -1px; /* Overlap border */
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600; /* Bolder */
  font-size: 0.9rem;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.tab-button:hover {
  color: var(--color-primary);
  background-color: var(--bg-muted); /* Subtle hover background */
  border-bottom-color: var(--color-primary-light); /* Lighter border on hover */
}

.tab-button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Optional: Remove the ::after animation if border is sufficient */
/* .tab-button::after { ... } */

/* ===== TAB CONTENT ===== */
.tab-content {
  position: relative;
  /* Add some vertical space */
  margin-top: var(--space-6);
}

.tab-pane {
  display: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.tab-pane.active {
  display: block;
  opacity: 1;
  animation: fadeIn 0.3s ease forwards;
}

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

/* ===== PANEL STYLES (Tables, Insights, Patterns) ===== */
.transactions-panel, .insights-panel, .pattern-analysis-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-8);
  overflow: hidden; /* Contain children */
  border: 1px solid var(--border-light);
}

.panel-header, .insights-header, .pattern-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle); /* Subtle background for headers */
}
.panel-header { /* Specific layout for transaction tables */
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
}
.header-content { flex: 1 1 auto; min-width: 250px; } /* Allow content to grow */
.header-summary { display: flex; gap: var(--space-6); flex-shrink: 0; flex-wrap: wrap; }
.summary-item { display: flex; flex-direction: column; }
.summary-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }
.summary-value { font-size: 1rem; font-weight: 600; color: var(--text-primary); }


.panel-header h2, .insights-header h2, .pattern-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-2) 0; /* Add bottom margin */
}
.header-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

/* ===== FILTER SECTION ===== */
.filter-section {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.search-box {
  margin-bottom: var(--space-4);
  position: relative; /* For clear button positioning */
}

.search-input {
  width: 100%;
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-4); /* Space for clear button */
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background-color: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.clear-button {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.4rem; /* Larger 'x' */
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
    padding: var(--space-1);
    transition: color var(--transition-fast);
}
.clear-button:hover { color: var(--text-primary); }

.filter-controls {
  display: flex;
  gap: var(--space-6); /* Increased gap */
  flex-wrap: wrap;
  align-items: center;
}

.date-range,
.amount-range {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-range input,
.amount-range input {
  width: 130px; /* Slightly wider */
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background-color: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.date-range input:focus,
.amount-range input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.date-range label,
.amount-range label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-right: var(--space-1);
}
.date-range span, .amount-range span { /* 'to' text */
    color: var(--text-muted);
    font-size: 0.875rem;
}

.id-filter-info {
    margin-top: var(--space-3);
    font-size: 0.85em;
    color: var(--color-primary);
    background-color: rgba(59, 130, 246, 0.1);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    display: inline-block; /* Or block if needed */
}

/* ===== TABLE STYLES ===== */
.table-container {
  /* Removed background/shadow - now on parent panel */
  overflow-x: auto; /* Ensure horizontal scroll if needed */
}

.transactions-table {
  width: 100%;
  border-collapse: collapse; /* Use collapse for cleaner lines */
  /* border-spacing: 0; */ /* Not needed with collapse */
}

.transactions-table th {
  background: var(--bg-subtle);
  padding: var(--space-3) var(--space-5); /* Adjust padding */
  text-align: left;
  font-weight: 600; /* Bolder */
  color: var(--text-secondary);
  font-size: 0.8rem; /* Smaller header text */
  border-bottom: 2px solid var(--border-medium); /* Thicker bottom border */
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.transactions-table td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.875rem; /* Slightly smaller body text */
  transition: background-color var(--transition-fast);
  vertical-align: middle; /* Align content vertically */
}

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

.transactions-table tr:hover td {
  background-color: var(--bg-muted);
}

/* Description cell adjustments */
.description-cell {
    line-height: 1.4; /* Improve readability */
}
.badges-container {
    margin-top: var(--space-1);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Amount column */
.amount-column { text-align: right; }
.amount-cell {
  font-family: var(--font-mono);
  text-align: right;
  font-weight: 500;
  white-space: nowrap; /* Prevent amount wrapping */
}
.amount-cell.positive { color: var(--status-positive); }
.amount-cell.negative { color: var(--status-negative); }

/* Actions column */
.actions-column { text-align: right; width: 1%; white-space: nowrap; }
.actions-cell { text-align: right; }

/* Sorting */
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
  position: relative;
  padding-right: calc(var(--space-5) + 1rem); /* Space for icon */
}
th.sortable:hover { color: var(--color-primary); }

.sort-icon {
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}
th.sortable:hover .sort-icon { opacity: 1; }
.sort-icon::after { content: '↕'; /* Default icon */ }
th.sortable.asc .sort-icon::after { content: '↑'; }
th.sortable.desc .sort-icon::after { content: '↓'; }

/* No results message */
.no-results-message {
    padding: var(--space-8);
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== BUTTON STYLES ===== */
/* Base Button */
.button, .export-button, .action-button, .close-button-bottom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}
.button:focus-visible, .export-button:focus-visible,
.action-button:focus-visible, .close-button-bottom:focus-visible {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3);
}
.button:disabled, .export-button:disabled,
.action-button:disabled, .close-button-bottom:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Primary Button */
.export-button.primary {
  background-color: var(--color-primary);
  color: var(--text-white);
  border-color: var(--color-primary);
}
.export-button.primary:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Secondary Button */
.export-button.secondary, .action-button, .close-button-bottom {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}
.export-button.secondary:hover:not(:disabled),
.action-button:hover:not(:disabled),
.close-button-bottom:hover:not(:disabled) {
  border-color: var(--border-focus);
  color: var(--color-primary);
  /* background-color: var(--bg-subtle); */ /* Optional subtle background */
  box-shadow: var(--shadow-sm);
}

/* Link Button */
.link-button {
  background: none;
  border: none;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: inherit; /* Inherit size */
  font-weight: inherit;
  transition: color var(--transition-fast);
}
.link-button:hover { color: var(--color-primary-dark); }
.link-button.small { font-size: 0.85em; }


/* Close Button (Modal Header) */
.close-button {
  background: none;
  border: none;
  font-size: 1.75rem; /* Larger */
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 32px; /* Explicit size */
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.close-button:hover {
  color: var(--text-primary);
  background-color: var(--bg-muted);
}

/* ===== PANEL FOOTER (Table Pagination/Export) ===== */
.panel-footer {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping */
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  /* border-radius: 0 0 var(--radius-lg) var(--radius-lg); */ /* Only needed if panel isn't parent */
  gap: var(--space-4);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.pagination-info {
  color: var(--text-muted);
  font-size: 0.875rem;
  white-space: nowrap;
}
/* Add styles for actual pagination buttons if implemented */

/* ===== EXPORT PANEL (Bottom of Page) ===== */
.export-panel {
    margin-top: var(--space-8);
    padding: var(--space-6);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}
.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    justify-content: center; /* Center buttons */
}

/* ===== VISUALIZATION PANEL & CHARTS ===== */
.visualization-panel {
  /* Styles from .panel-styles apply */
  padding: var(--space-6);
}

.chart-section {
  margin-bottom: var(--space-8);
}
.chart-section:last-child { margin-bottom: 0; }

.chart-section h3 {
  font-size: 1.1rem; /* Slightly larger */
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4); /* Reduced margin */
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Adjust min size */
  gap: var(--space-6);
}
.chart-section.full-width { grid-column: 1 / -1; }

/* Timeline specific styles (Example - Requires JS positioning) */
.timeline-container {
  overflow-x: auto;
  padding: var(--space-4) 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #fdfdfd; /* Slightly different background */
}
.timeline-scroll { position: relative; min-height: 150px; padding-bottom: 30px; }
.timeline-chart { position: relative; height: 100%; border-left: 1px solid var(--border-medium); }
.timeline-axis { position: absolute; bottom: 0; left: 0; width: 100%; height: 30px; border-top: 1px solid var(--border-medium); }
.timeline-events { position: absolute; top: 10px; bottom: 30px; left: 0; width: 100%; }
.timeline-event { position: absolute; bottom: 5px; /* Slightly above axis */ width: 10px; height: 10px; border-radius: 50%; transform: translateX(-50%); cursor: pointer; transition: transform 0.2s ease; border: 1px solid white; }
.timeline-event:hover { transform: translateX(-50%) scale(1.4); z-index: 10; }
.missing-event { background-color: var(--color-primary); }
.remove-event { background-color: var(--color-danger); }
.month-marker { position: absolute; bottom: 0; height: 100%; display: flex; flex-direction: column; align-items: center; transform: translateX(-50%); pointer-events: none; }
.marker-line { width: 1px; height: 6px; background: var(--text-light); flex-shrink: 0; }
.marker-label { font-size: 0.7rem; color: var(--text-light); white-space: nowrap; margin-top: 4px; writing-mode: vertical-lr; transform: rotate(180deg) translateX(5px); }

/* Donut Chart Styles */
.donut-container { /* Styles from modern-reconciliation.css assumed */ }
.donut-wrapper { /* Styles from modern-reconciliation.css assumed */ }
.donut { /* Styles from modern-reconciliation.css assumed */ }
.donut-ring { fill: none; stroke: var(--border-light); stroke-width: 12; }
.donut-segment { fill: none; stroke-width: 12; stroke-linecap: round; /* Rounded ends */ transition: stroke-dasharray var(--transition-slow); }
.donut-segment.missing { stroke: var(--color-primary); }
.donut-segment.remove { stroke: var(--color-danger); }
.donut-total { /* Styles from modern-reconciliation.css assumed */ }
.donut-legend { /* Styles from modern-reconciliation.css assumed */ }

/* Distribution Chart */
.distribution-content { /* Styles from modern-reconciliation.css assumed */ }
.distribution-bars { /* Styles from modern-reconciliation.css assumed */ }
.distribution-bar-wrapper { /* Styles from modern-reconciliation.css assumed */ }
.bar-container { /* Styles from modern-reconciliation.css assumed */ }
.bar { /* Styles from modern-reconciliation.css assumed */ background: linear-gradient(to top, var(--color-primary), var(--color-primary-light)); }
.bar-value { /* Styles from modern-reconciliation.css assumed - ensure visibility */ display: block; z-index: 1; }
.bar-label { /* Styles from modern-reconciliation.css assumed */ }

/* Trend Chart */
.trend-container { /* Styles from modern-reconciliation.css assumed */ }
.trend-grid { /* Styles from modern-reconciliation.css assumed */ }
.trend-column { /* Styles from modern-reconciliation.css assumed */ }
.trend-bars { /* Styles from modern-reconciliation.css assumed */ }
.trend-bar { /* Styles from modern-reconciliation.css assumed */ border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.trend-bar.missing { background: linear-gradient(to top, var(--color-primary-dark), var(--color-primary-light)); }
.trend-bar.remove { background: linear-gradient(to top, var(--color-danger), #f87171); }
.trend-label { /* Styles from modern-reconciliation.css assumed */ }
.trend-legend { /* Styles from modern-reconciliation.css assumed */ }

/* ===== INSIGHTS & PATTERNS ===== */
/* Specific headers */
.insights-header h2, .pattern-header h2 { margin-bottom: var(--space-4); }
/* Quick Stats */
.quick-stats { display: flex; flex-wrap: wrap; gap: var(--space-6); }
.stat-item { /* Styles from modern-reconciliation.css assumed */ }
.stat-label { /* Styles from modern-reconciliation.css assumed */ }
.stat-value { /* Styles from modern-reconciliation.css assumed */ }
.stat-danger { color: var(--status-negative); }
.stat-warning { color: var(--color-warning); }

/* Insight Card */
.insights-content, .recommendations-section { padding: var(--space-6); }
.insights-content { display: flex; flex-direction: column; gap: var(--space-5); }

.insight-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: box-shadow var(--transition-normal);
  background: var(--bg-card);
}
.insight-card.expanded { box-shadow: var(--shadow-md); }

.card-header {
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  cursor: pointer;
  background: var(--bg-subtle);
  transition: background-color var(--transition-fast);
  border-bottom: 1px solid transparent; /* Prepare for border */
}
.insight-card.expanded .card-header { border-bottom-color: var(--border-light); }
.card-header:hover { background: var(--bg-muted); }

.insight-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-muted); margin-top: 3px; }
.header-content { flex: 1; }
.header-content h4 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-1); }
.header-content p { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.4; }
.expand-icon { width: 18px; height: 18px; stroke-width: 2.5; flex-shrink: 0; margin-left: auto; margin-top: 4px; color: var(--text-muted); transition: transform var(--transition-normal); transform-origin: center; }
.insight-card.expanded .expand-icon { transform: rotate(180deg); }

/* Severity Indicators */
.severity-high .card-header { border-left: 4px solid var(--status-negative); }
.severity-medium .card-header { border-left: 4px solid var(--color-warning); }
.severity-low .card-header { border-left: 4px solid var(--status-positive); }
/* Add padding to compensate for border */
.severity-high .card-header, .severity-medium .card-header, .severity-low .card-header {
    padding-left: calc(var(--space-5) - 4px);
}


.card-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
  padding: 0 var(--space-5);
}
.insight-card.expanded .card-details {
  max-height: 800px; /* Generous height */
  padding: var(--space-5);
}
.details-section { margin-top: var(--space-4); }
.details-section:first-child { margin-top: 0; }
.details-section p:first-child { margin-bottom: var(--space-2); font-weight: 500; color: var(--text-secondary); }
.details-list { list-style: disc; padding-left: var(--space-5); margin-top: var(--space-2); color: var(--text-secondary); font-size: 0.875rem; display: flex; flex-direction: column; gap: var(--space-1); }

/* Pattern Analysis Grid */
.pattern-analysis-panel .pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-6);
    padding: var(--space-6);
}
.pattern-analysis-panel .insights-section,
.pattern-analysis-panel .recommendations-section {
    padding: var(--space-6);
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-subtle); /* Differentiate sections */
}
.pattern-analysis-panel .insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
}
.pattern-analysis-panel .recommendations-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.pattern-section {
    /* background: white; */ /* Let grid manage background or keep individual */
    /* border: 1px solid var(--border-light); */
    /* border-radius: var(--radius-lg); */
    /* padding: var(--space-5); */
    /* box-shadow: var(--shadow-sm); */
    min-height: 150px; /* Ensure sections have some height */
}
.pattern-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: var(--space-2);
}

/* Recommendation Card */
.recommendations-list { /* Styles from modern-reconciliation.css assumed */ }
.recommendation-item {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left-width: 4px;
  transition: all var(--transition-fast);
}
.recommendation-item:hover {
  background: var(--bg-subtle);
  box-shadow: var(--shadow-sm);
}
.recommendation-item.priority-high { border-left-color: var(--status-negative); }
.recommendation-item.priority-medium { border-left-color: var(--color-warning); }
.recommendation-item.priority-low { border-left-color: var(--status-positive); }

.recommendation-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.recommendation-header h4 { font-size: 1rem; font-weight: 600; color: var(--text-primary); flex-grow: 1; }
.recommendation-item p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: var(--space-3); }
.recommendation-steps { list-style: decimal; font-size: 0.875rem; color: var(--text-secondary); padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.recommendation-details { /* Styles from modern-reconciliation.css assumed */ }


/* Badges */
.severity-badge, .priority-badge {
  font-size: 0.7rem; /* Smaller */
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.severity-badge.high, .priority-badge.high { background: rgba(239, 68, 68, 0.1); color: var(--status-negative); }
.severity-badge.medium, .priority-badge.medium { background: rgba(245, 158, 11, 0.1); color: var(--color-warning); }
.severity-badge.low, .priority-badge.low { background: rgba(16, 185, 129, 0.1); color: var(--status-positive); }

.match-badge {
  display: inline-block; /* Allow margin/padding */
  font-size: 0.75rem;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  white-space: nowrap;
  font-weight: 500;
  line-height: 1.2; /* Adjust line height */
  border: 1px solid transparent; /* Base border */
}
.match-badge.high { background: rgba(16, 185, 129, 0.1); color: var(--status-positive); border-color: rgba(16, 185, 129, 0.3); }
.match-badge.medium { background: rgba(245, 158, 11, 0.1); color: var(--color-warning); border-color: rgba(245, 158, 11, 0.3); }
.match-badge.low { background: rgba(100, 116, 139, 0.1); color: var(--text-muted); border-color: rgba(100, 116, 139, 0.3); }
/* Batch Badges */
.match-badge.batch { background: rgba(59, 130, 246, 0.1); color: var(--color-primary); border-color: rgba(59, 130, 246, 0.3); }
.match-badge.batch.component { background: rgba(99, 102, 241, 0.1); color: var(--color-secondary); border-color: rgba(99, 102, 241, 0.3); } /* Different color for components */

/* ===== MODAL STYLES ===== */
.modal {
  display: none; /* Controlled by JS */
  position: fixed;
  inset: 0; /* Replaces top, left, width, height */
  background-color: rgba(0, 0, 0, 0.6); /* Darker backdrop */
  z-index: var(--z-modal-backdrop);
  display: flex; /* Use flex for centering */
  align-items: center;
  justify-content: center;
  padding: var(--space-4); /* Padding for small screens */
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.modal[style*="display: flex"] { opacity: 1; } /* Fade in */

.modal-content {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px; /* Slightly wider modal */
  max-height: 90vh;
  display: flex; /* Use flex for layout */
  flex-direction: column;
  overflow: hidden; /* Prevent content overflow */
  opacity: 0; /* For animation */
  transform: scale(0.95);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}
.modal[style*="display: flex"] .modal-content { opacity: 1; transform: scale(1); } /* Scale/fade in content */

.modal-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0; /* Prevent header shrinking */
}
.modal-header h2 { margin: 0; font-size: 1.2rem; font-weight: 600; color: var(--text-primary); }

.modal-body {
  padding: var(--space-6);
  overflow-y: auto; /* Allow body scrolling */
  flex-grow: 1; /* Allow body to take up space */
}

.detail-row { margin-bottom: var(--space-4); }
.detail-row:last-child { margin-bottom: 0; }
.detail-row label { font-weight: 500; color: var(--text-muted); margin-bottom: var(--space-1); font-size: 0.8rem; display: block; text-transform: uppercase; letter-spacing: 0.03em; }
.detail-row span { font-size: 0.95rem; color: var(--text-primary); line-height: 1.4; }
.detail-row span#modalId { font-size: 0.8em; color: #666; word-break: break-all; }
.detail-row span.positive { color: var(--status-positive); }
.detail-row span.negative { color: var(--status-negative); }

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  background-color: var(--bg-subtle);
  flex-shrink: 0; /* Prevent footer shrinking */
}

/* Modal Match/Batch Sections */
#modalExtraSections { margin-top: var(--space-6); }
.matches-section, .batch-matches-section {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--border-light); /* Dashed separator */
}
.matches-section h3, .batch-matches-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--text-secondary); /* Less prominent header */
}
/* Match box styling */
.potential-match, .batch-match {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.potential-match { border-left-color: var(--color-warning); }
.batch-match { border-left-color: var(--color-primary); }
.match-confidence, .batch-match-header { font-weight: 600; margin-bottom: var(--space-3); font-size: 0.9rem; }
.batch-match-header { display: flex; justify-content: space-between; align-items: center; }
.batch-match-confidence { background-color: var(--color-primary); color: white; /* Styles from .badge apply */ }
.batch-summary { font-size: 0.9em; margin-bottom: var(--space-3); color: var(--text-secondary); }
.batch-components { margin-top: var(--space-3); }
.batch-component-header { font-weight: 600; margin-bottom: var(--space-2); color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.batch-component { display: flex; flex-wrap: nowrap; /* Prevent wrapping */ justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border-light); font-size: 0.85rem; }
.batch-component:last-child { border-bottom: none; }
.batch-component.batch-transaction { background: rgba(59, 130, 246, 0.05); padding: var(--space-2); margin-bottom: var(--space-3); border-radius: var(--radius-sm); font-weight: 500; border-bottom: none; }
.component-date { min-width: 75px; color: var(--text-muted); flex-shrink: 0; }
.component-description { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 var(--space-2); }
.component-amount { min-width: 90px; text-align: right; font-weight: 500; font-family: var(--font-mono); flex-shrink: 0; }
.batch-total { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border-medium); text-align: right; font-weight: 600; font-size: 0.9rem; }
.difference-amount { font-size: 0.8rem; color: var(--text-muted); font-weight: normal; margin-top: var(--space-1); }

/* Confidence colors */
.high-confidence { color: var(--status-positive); }
.medium-confidence { color: var(--color-warning); }
.low-confidence { color: var(--text-muted); }

/* ===== UTILITY CLASSES ===== */
.info-tooltip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1rem; height: 1rem; border-radius: 50%;
  background: var(--bg-muted); color: var(--text-muted);
  font-size: 0.7rem; font-weight: bold; cursor: help;
  transition: all var(--transition-fast); user-select: none;
}
.info-tooltip:hover { background: var(--color-primary-light); color: white; }

.no-data {
  display: flex; align-items: center; justify-content: center;
  min-height: 150px; /* Ensure minimum height */
  padding: var(--space-6);
  color: var(--text-muted); font-style: italic;
  background: var(--bg-subtle); border-radius: var(--radius-md);
  flex-direction: column; gap: var(--space-2); text-align: center;
}
.no-data::before { content: "∅"; font-size: 1.5rem; opacity: 0.5; } /* Empty set symbol */

/* Spin Animation */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

/* ===== RESPONSIVE STYLES ===== */
@media (max-width: 768px) {
  .results-container { padding: var(--space-4); }
  .results-header { flex-direction: column; align-items: flex-start; }
  .header-meta { text-align: left; margin-top: var(--space-2); width: 100%; }
  .filter-controls { flex-direction: column; align-items: stretch; gap: var(--space-4); }
  .date-range, .amount-range { width: 100%; justify-content: space-between; }
  .date-range input, .amount-range input { width: calc(50% - 2rem); /* Adjust width */ }
  .panel-footer { flex-direction: column; align-items: stretch; gap: var(--space-4); }
  .export-buttons { justify-content: stretch; }
  .export-buttons button { flex-grow: 1; }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .results-container { padding: var(--space-3); }
  .header-meta h1 { font-size: 1.5rem; }
  .summary-cards { gap: var(--space-4); }
  .card-value { font-size: 1.6rem; }
  .tab-navigation { gap: 0; }
  .tab-button { padding: var(--space-2) var(--space-3); font-size: 0.85rem; }
  .panel-header, .insights-header, .pattern-header, .filter-section, .modal-body, .modal-footer, .panel-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
  .transactions-table th, .transactions-table td { padding: var(--space-2) var(--space-3); font-size: 0.8rem; }
  .actions-column, .actions-cell { padding-right: var(--space-2); } /* Reduce padding */
  .modal-content { max-width: 95%; }
  .batch-component { font-size: 0.8rem; gap: var(--space-2); }
  .component-date { min-width: 65px; }
  .component-amount { min-width: 70px; }
}

/* ===== PRINT STYLES ===== */
@media print {
  body { background-color: #fff; color: #000; }
  .results-container { padding: 0; max-width: 100%; margin: 0; }
  .results-header button, .tab-navigation, .filter-section, .export-panel, .action-button, .link-button, .close-button, .close-button-bottom, .info-tooltip, .expand-icon { display: none !important; }
  .summary-card, .panel-header, .insights-panel, .pattern-analysis-panel, .table-container, .chart-section, .modal-content { box-shadow: none !important; border: 1px solid #ccc !important; border-radius: 0 !important; background: #fff !important; color: #000 !important; page-break-inside: avoid; margin-bottom: 20pt; }
  .summary-card { border-left-width: 3pt !important; }
  .summary-card.positive { border-left-color: #10b981 !important; }
  .summary-card.negative { border-left-color: #ef4444 !important; }
  .card-value, .card-content h3, .impact-label, .header-meta h1, .header-meta span, .text-primary, .text-secondary, .text-muted, .text-light { color: #000 !important; }
  .card-value.positive, .impact-label.positive, .amount-cell.positive { color: #056d4e !important; } /* Darker Green */
  .card-value.negative, .impact-label.negative, .amount-cell.negative { color: #b91c1c !important; } /* Darker Red */
  .table-container { overflow: visible !important; }
  .transactions-table th { background: #eee !important; color: #000 !important; border-bottom-width: 1pt !important; border-color: #aaa !important; }
  .transactions-table td { border-color: #ddd !important; }
  a { text-decoration: none; color: inherit; }
  .visualization-panel { padding: 10pt; }
  /* Ensure charts render - might need specific library print settings */
  .donut, .distribution-bars, .trend-grid { height: auto !important; }
  @page { margin: 0.75in; }
}