:root {
  /* Ant Design 5.0 Tokens */
  --bg: #f5f5f5;
  /* Ant Layout Background */
  --panel: #ffffff;
  /* Ant Component Background */
  --text: rgba(0, 0, 0, 0.88);
  /* Ant Text Primary */
  --muted: rgba(0, 0, 0, 0.45);
  /* Ant Text Secondary */
  --border: #d9d9d9;
  /* Ant Border Color */

  /* Brand Colors - Ant Blue */
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-light: #e6f4ff;
  /* Ant Blue-1 */
  --primary-bg: #f0f5ff;
  /* Ant Blue-1 (for backgrounds) */

  /* Accents */
  --success: #52c41a;
  --danger: #ff4d4f;
  --warning: #faad14;

  /* UI Elements */
  --radius-sm: 4px;
  --radius-md: 6px;
  /* Ant Base Radius */
  --radius-lg: 8px;
  /* Ant Large Radius */

  /* New Variables for Component consistency */
  --bg-subtle: #fafafa;
  --bg-disabled: #f5f5f5;

  /* Shadows */
  --shadow-sm: 0 2px 0 rgba(0, 0, 0, 0.02);
  --shadow-card: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02);

  --font-main: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

html {
  scroll-behavior: smooth;
}

html[data-theme="dark"] {
  --bg: #000000;
  /* Ant Dark Layout */
  --panel: #141414;
  /* Ant Dark Component */
  --text: rgba(255, 255, 255, 0.85);
  --muted: rgba(255, 255, 255, 0.45);
  --border: #424242;

  --primary: #1668dc;
  /* Ant Dark Blue */
  --primary-hover: #1677ff;
  --primary-light: #111d2c;
  --primary-bg: #111a2c;

  --bg-subtle: #1f1f1f;
  --bg-disabled: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 2px 0 rgba(0, 0, 0, 0);
  --shadow-card: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px 0 rgba(0, 0, 0, 0.3);
}

/* Global Reset & Base */
* {
  box-sizing: border-box;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* Focus States for Accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  /* Soft grey */
  border-radius: 5px;
  border: 2px solid var(--bg);
  /* Padding effect */
}

::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

/* Focus States */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.error {
  background: #fff2f0;
  border: 1px solid #ffccc7;
  color: #ff4d4f;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

.error::before {
  content: "⚠️";
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  /* Changed from height: 100vh to min-height */
  display: grid;
  grid-template-columns: 280px 1fr;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  /* Ant-like compact padding */
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 8px;
}

.app-header {
  padding-bottom: 8px;
  border-bottom: 1px solid transparent;
}

.app-name {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  /* Clean text, no gradient */
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
  font-weight: 400;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

/* Sidebar List */
.sidebar-search input {
  width: 100%;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  /* 6px */
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
  transition: all 0.2s ease;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
  /* Ant focus ring */
}

.analysis-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analysis-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
  user-select: none;
  color: var(--text);
  margin-bottom: 4px;
}

.analysis-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.analysis-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.analysis-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

/* --- Main Layout --- */
.content {
  padding: 0 0 40px 0;
  /* No top padding, let topbar handle its sticky position */
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Container for sections below topbar */
.content> :not(.topbar):not(.error) {
  margin-left: 40px;
  margin-right: 40px;
}

.content>.error {
  margin: 20px 40px 16px !important;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  height: 50px;
  padding: 0 40px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.heading {
  font-size: 18px;
  /* Slightly smaller to fit better in 50px if needed */
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.title-wrap .muted {
  font-size: 13px;
  line-height: 1.5;
}

.actions-right {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Buttons */
/* Buttons */
.btn {
  border: 1px solid transparent;
  /* Ant buttons usually have borders */
  font-family: inherit;
  font-size: 14px;
  height: 32px;
  /* Ant Default Height */
  padding: 4px 15px;
  border-radius: var(--radius-md);
  /* 6px */
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
  user-select: none;
  font-weight: 400;
  /* Regular weight */
}

.btn:active {
  transform: none;
  /* remove scale effect */
}

.btn:disabled {
  color: rgba(0, 0, 0, 0.25);
  background: var(--bg-disabled);
  border-color: var(--border);
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 0 rgba(5, 145, 255, 0.1);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.2);
}

.btn-secondary {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
}

.btn-secondary:hover {
  color: var(--primary-hover);
  border-color: var(--primary-hover);
  background: var(--panel);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--primary);
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-weight: 400;
}

.btn-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.btn-sm {
  height: 24px;
  padding: 0 7px;
  font-size: 12px;
  border-radius: 4px;
  /* Slightly smaller radius for small buttons */
}

.btn-xs {
  height: 24px;
  padding: 0 7px;
  font-size: 12px;
  border-radius: 4px;
}

.btn-lg {
  height: 40px;
  padding: 6px 15px;
  font-size: 16px;
  border-radius: 8px;
}

/* Input Section */
.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  /* Ant uses 16px or 24px gutters usually */
}

.input-col {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s;
}

.input-col:focus-within {
  /* Ant doesn't usually highlight the whole card, but we'll modify the border slightly */
  border-color: #d9d9d9;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editable-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.editable-label:hover {
  background: rgba(0, 0, 0, 0.04);
}

.count-badge {
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid transparent;
}

/* Textarea with "input" look */
/* Transformation Toolbars */
.transform-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.transform-toolbar .btn-xs {
  height: 22px;
  min-width: 22px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--muted);
}

.transform-toolbar .btn-xs:hover {
  color: var(--primary);
  background: rgba(0, 0, 0, 0.04);
}

.list-input {
  width: 100%;
  min-height: 300px;
  padding: 8px 12px;
  margin-top: -12px;
  /* Remove gap from .input-col parent */
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background: var(--panel);
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  /* Professional Mono */
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  color: var(--text);
  transition: all 0.2s;
}

.list-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
}

/* label-editor style moved to UX Improvements section */

/* Action Bar (Compare Button) */
.action-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  margin-bottom: 24px;
}

.btn-group {
  display: flex;
  align-items: center;
}

.btn-group .btn {
  border-radius: 0;
  margin-left: -1px;
}

.btn-group .btn:first-child {
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
  margin-left: 0;
}

.btn-group .btn:last-child {
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.btn-group .btn:hover {
  z-index: 2;
}

#clearBtn {
  margin-right: auto;
}

/* Options Bar */
.options {
  background: var(--panel);
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
  /* Extra space above options */
  margin-bottom: 8px;
  /* Extra space below options */
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  user-select: none;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

/* Stats Cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 24px;
}

.stat {
  background: var(--panel);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.stat.primary .num,
.stat.primary .label {
  color: white;
}

/* Fuzzy Match Indicator */
.fuzzy-match-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-style: italic;
}

.fuzzy-icon {
  font-weight: 800;
  font-size: 1.2em;
  color: var(--warning);
  user-select: none;
}

.num {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Results Tables */
.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.table-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-card-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  /* Ant clean white headers usually */
  flex-wrap: wrap;
  gap: 12px;
}

.table-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.table-tools .search {
  padding: 4px 11px;
  border-radius: var(--radius-md);
  /* 6px */
  border: 1px solid var(--border);
  font-size: 14px;
  transition: all 0.2s;
}

.table-tools .search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
}

.list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-scroll-container {
  max-height: 500px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  /* Visually separate from tools header */
}

.list-table th {
  text-align: left;
  padding: 4px 16px;
  /* Drastically reduced for 36px height */
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  /* Explicit line height */
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  /* Ant Table Header Background */
  transition: background 0.2s;
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  /* Explicit height preference */
  box-sizing: border-box;
}

.list-table td {
  padding: 4px 16px;
  /* Drastically reduced for 36px height */
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 20px;
  /* Explicit line height */
  color: var(--text);
  transition: background 0.2s;
  height: 36px;
  /* Explicit height preference */
  box-sizing: border-box;
}

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

.list-table tr:hover td {
  background: var(--bg-subtle);
}

.copy-btn {
  color: var(--primary);
  opacity: 1;
  /* Always visible for better UX in Ant */
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.copy-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.hidden {
  display: none !important;
}

/* --- UX Improvements --- */

/* Edit Button for Labels */
.edit-btn {
  font-size: 14px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s;
  padding: 4px;
  cursor: pointer;
  background: none;
  border: none;
}

.label-info:hover .edit-btn {
  opacity: 1;
}

.edit-btn:focus {
  opacity: 1;
}

.edit-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 4px;
}

/* Tooltips */
.has-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tip {
  width: 18px;
  height: 18px;
  background: var(--muted);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  margin-left: 6px;
  cursor: help;
  transition: background 0.2s;
}

.tip:hover {
  background: var(--primary);
}

.has-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: #333;
  color: white;
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: normal;
  width: max-content;
  min-width: 200px;
  max-width: 280px;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  line-height: 1.5;
  text-align: center;
}

.has-tooltip:hover::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #333;
  margin-top: -4px;
}

/* FAQ Section (Accordion Style) */
.faq-section {
  margin-top: 60px;
  border-top: 1px solid var(--border);
  padding-top: 40px;
  padding-bottom: 80px;
}

.faq-section h2 {
  font-size: 28px;
  margin-bottom: 32px;
  text-align: center;
  font-weight: 800;
  color: var(--text);
}

.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.faq-item {
  background: var(--panel);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}

.faq-item[open] {
  box-shadow: var(--shadow-card);
  border-color: var(--primary);
}

.faq-item summary {
  padding: 12px 20px;
  cursor: pointer;
  list-style: none;
  /* Hide default triangle */
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary:hover {
  background: var(--bg);
}

.faq-item summary h3 {
  margin: 0;
  font-size: 16px;
  display: inline;
}

.faq-item summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 400;
  color: var(--muted);
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
  content: '+';
  /* Or unicode cross */
}

.faq-item div {
  padding: 0 20px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  border-top: 1px solid transparent;
}

.faq-item[open] div {
  /* border-top-color: var(--border); */
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Label Row & Editing */
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  /* Prevent layout shift */
}

.label-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* When editing, hide label info and show input */
.label-row.editing .label-info {
  display: none;
}

.label-row.editing .label-editor {
  display: block;
  order: -1;
  /* Move to start (Left) */
  margin-right: auto;
  /* Push others to right if space exists, though space-between handles it */
}

.label-editor {
  display: none;
  font-size: 16px;
  padding: 6px 12px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  width: 100%;
  max-width: 180px;
  /* Limit width */
  margin-right: 16px;
}

/* Import Button */
.row-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.import-hint {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.row-actions label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: var(--radius-md);
  /* 6px */
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  transition: all 0.2s;
}

.row-actions label:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
  background: var(--bg);
}

.empty-illustration {
  font-size: 48px;
  margin-bottom: 16px;
  animation: wave 2s infinite;
  transform-origin: 70% 70%;
  display: inline-block;
}

@keyframes wave {
  0% {
    transform: rotate(0.0deg)
  }

  10% {
    transform: rotate(14.0deg)
  }

  20% {
    transform: rotate(-8.0deg)
  }

  30% {
    transform: rotate(14.0deg)
  }

  40% {
    transform: rotate(-4.0deg)
  }

  50% {
    transform: rotate(10.0deg)
  }

  60% {
    transform: rotate(0.0deg)
  }

  100% {
    transform: rotate(0.0deg)
  }
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 20px;
}

/* Mobile Action Bar */
.mobile-action-bar {
  display: none;
  /* Hidden on desktop */
}

/* Responsive */
@media (max-width: 900px) {
  /* ... existing responsive styles ... */
}

/* Modal System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--panel);
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Shortcuts Modal */
.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
}

.shortcuts-table tr {
  border-bottom: 1px solid var(--border);
}

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

.shortcuts-table td {
  padding: 12px 0;
}

.shortcuts-table td:last-child {
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  color: var(--text);
  display: inline-block;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  height: fit-content;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.mini-modal {
  max-width: 450px;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-footer {
  flex-shrink: 0;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
}

/* Diff View Layout */
.diff-view-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
  background: var(--bg-subtle);
}

.diff-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.diff-pane:last-child {
  border-right: none;
}

.pane-header {
  padding: 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.pane-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 0;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 20px;
  background: var(--panel);
}

/* Diff Highlighting */
.diff-line {
  display: flex;
  width: 100%;
}

.diff-num {
  width: 40px;
  flex-shrink: 0;
  text-align: right;
  padding: 0 10px;
  color: var(--muted);
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  user-select: none;
}

.diff-text {
  padding: 0 12px;
  white-space: pre;
  flex: 1;
}

.line-added {
  background: #f6ffed;
}

.line-added .diff-num {
  background: #d9f7be;
}

.line-added .diff-text {
  color: #389e0d;
}

.line-removed {
  background: #fff1f0;
}

.line-removed .diff-num {
  background: #ffccc7;
}

.line-removed .diff-text {
  color: #cf1322;
}

.line-empty {
  background: var(--bg-subtle);
  color: transparent;
}

.line-empty .diff-num {
  border-right-color: transparent;
}

html[data-theme="dark"] .line-added {
  background: rgba(35, 120, 4, 0.15);
}

html[data-theme="dark"] .line-added .diff-text {
  color: #49aa19;
}

html[data-theme="dark"] .line-removed {
  background: rgba(166, 29, 36, 0.15);
}

html[data-theme="dark"] .line-removed .diff-text {
  color: #d32029;
}

/* ========================================
   VISUAL INSIGHTS SECTION
   ======================================== */

/* Visual Insights Container */
.visual-insights {
  padding: 24px;
  margin-top: 32px;
  margin-bottom: 32px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.insights-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.insights-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 0;
}

@media (max-width: 1024px) {
  .insights-grid {
    grid-template-columns: 1fr;
  }
}

/* Venn Diagram */
.venn-container {
  text-align: center;
  padding: 20px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.venn-container h3 {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

#vennDiagram {
  width: 100%;
  max-width: 400px;
  height: 300px;
  margin: 0 auto;
  display: block;
}

.venn-circle {
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.venn-circle:hover {
  opacity: 0.7 !important;
  filter: brightness(1.1);
}

.venn-circle:active {
  opacity: 0.6 !important;
}

.venn-label {
  font-family: var(--font-main);
}

.venn-subtitle {
  font-family: var(--font-main);
}

.venn-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Distribution Chart */
.distribution-container {
  padding: 20px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.distribution-container h3 {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.chart-row {
  display: grid;
  grid-template-columns: 120px 1fr 100px;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.chart-row:last-child {
  margin-bottom: 0;
}

.chart-label {
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-container {
  height: 28px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.chart-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
  font-weight: 600;
  position: relative;
  min-width: 2px;
}

.chart-bar:hover {
  filter: brightness(1.05);
}

.chart-value {
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
}

.chart-percent {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}



/* Dark Mode Adjustments for Visual Insights */
html[data-theme="dark"] .venn-container,
html[data-theme="dark"] .distribution-container {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.1);
}


html[data-theme="dark"] .legend-color {
  border-color: rgba(255, 255, 255, 0.2);
}

html[data-theme="dark"] .chart-bar-container {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Responsiveness for Visual Insights */
@media (max-width: 768px) {
  .visual-insights {
    padding: 16px;
  }

  .insights-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .chart-row {
    grid-template-columns: 80px 1fr 80px;
    gap: 8px;
  }

  .chart-label {
    font-size: 11px;
  }

  .chart-value {
    font-size: 12px;
  }

  #vennDiagram {
    max-width: 100%;
    height: 250px;
  }

  .venn-container,
  .distribution-container {
    padding: 12px;
  }
}

/* Sortable Headers */
.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
  position: relative;
}

.sortable-header:hover {
  background-color: var(--bg-subtle) !important;
}

.sort-icon {
  display: inline-block;
  margin-left: 8px;
  font-size: 14px;
  opacity: 0.3;
  transition: opacity 0.2s;
  font-family: system-ui, -apple-system, sans-serif;
}

.sortable-header:hover .sort-icon {
  opacity: 0.6;
}

.sortable-header.asc .sort-icon,
.sortable-header.desc .sort-icon {
  opacity: 1;
  color: var(--primary);
  font-weight: bold;
}