/* ========================================
   Tagging & EDA Platform — Stylesheet
   ======================================== */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --primary-light: #cffafe;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --purple: #7c3aed;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
  --card-bg: #ffffff;
  --bg-muted: #f8fafc;
  --primary-hover: #0e7490;
  --font:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 14px;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden {
  display: none !important;
}

/* ---------- Login ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  z-index: 1000;
}
.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  padding: 48px;
  text-align: center;
  border: 1px solid #e2e8f0;
}
.login-logo {
  font-size: 64px;
  margin-bottom: 16px;
}
.login-card h2 {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}
.login-subtitle {
  color: #64748b;
  font-size: 14px;
  margin-bottom: 32px;
}
.login-error {
  display: none;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid #fca5a5;
}
.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 16px;
  background: #f8fafc;
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}
.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
  background: white;
}
.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(51, 65, 85, 0.3);
}
.login-home-btn {
  display: inline-block;
  margin-top: 16px;
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
}
.login-home-btn:hover {
  color: var(--primary);
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.2);
  position: sticky;
  top: 0;
  z-index: 50;
  height: 48px;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-title h1 {
  font-size: 17px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}
.home-btn {
  text-decoration: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: background 0.2s;
  color: white;
}
.home-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.header-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}
.tab-btn {
  padding: 0 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  height: 100%;
  display: flex;
  align-items: center;
  transition:
    color 0.2s,
    border-color 0.2s;
  white-space: nowrap;
}
.tab-btn:hover {
  color: rgba(255, 255, 255, 0.9);
}
.tab-btn.active {
  color: white;
  border-bottom-color: white;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-client select {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.header-client select option {
  background: #334155;
  color: white;
}
.summary-badge {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.header-separator {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
}
.header-user {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}
.header-btn {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.header-btn.logout {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.3);
}
.header-btn.logout:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ---------- Tab Content ---------- */
.tab-content {
  display: none;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ---------- Filters Bar (Tagging tab) ---------- */
.filters-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
  flex-shrink: 0;
}
.filters-row-main,
.filters-row-advanced {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  flex-wrap: wrap;
}
.filters-row-advanced {
  border-top: 1px dashed var(--border);
  background: var(--bg-muted);
  padding: 10px 20px;
}
.filter-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.filter-inline label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.filter-inline select,
.filter-inline input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  min-width: 90px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.filter-inline input {
  background-image: none;
  padding-right: 10px;
  cursor: text;
  -webkit-appearance: auto;
  appearance: auto;
}
.filter-search input {
  min-width: 220px;
}
.filter-inline select:hover {
  border-color: var(--primary);
}
.filter-inline select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.12);
}

/* Multi-select filter dropdowns */
.multi-filter {
  position: relative;
  min-width: 110px;
}
.multi-filter-display {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.multi-filter-display:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.12);
}
.mf-arrow {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.multi-filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-height: 220px;
  overflow-y: auto;
  min-width: 160px;
  padding: 4px 0;
  margin-top: 2px;
}
.multi-filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
}
.multi-filter-dropdown label:hover {
  background: var(--primary-light);
}
.multi-filter-dropdown input[type='checkbox'] {
  accent-color: var(--primary);
  min-width: auto;
}
.multi-filter .mf-tags {
  display: flex;
  gap: 3px;
  overflow: hidden;
}
.multi-filter .mf-tag {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.btn-batch {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: white;
  margin-left: auto;
  border: 1px solid #6d28d9;
}
.btn-batch:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

/* --- Filter toggle button --- */
.btn-filter-toggle {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-filter-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #e0f2fe;
}
.btn-filter-toggle.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ---------- Tagging Layout (left list + right detail) ---------- */
.tagging-layout {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- Instance List Panel (left) --- */
.instance-list-panel {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.instance-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.instance-list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.instance-list-scroll {
  flex: 1;
  overflow-y: auto;
}

/* --- Instance Card --- */
.instance-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}
.instance-card:hover {
  background: #f0f9ff;
}
.instance-card.selected {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding-left: 11px;
}
.instance-card-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}
.instance-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.instance-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-light);
}
.instance-card-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.instance-card-sku {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.instance-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.instance-card-status {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.tagged {
  background: var(--success);
}
.status-dot.untagged {
  background: var(--border);
}
.tag-count-sm {
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
  background: var(--success-bg);
  padding: 1px 5px;
  border-radius: 8px;
}

/* --- Detail Panel (right) --- */
.detail-panel {
  flex: 1;
  background: var(--bg);
  overflow-y: auto;
  min-width: 0;
}
.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
}
.detail-empty-icon {
  font-size: 48px;
  opacity: 0.4;
}
.detail-empty p {
  font-size: 14px;
  max-width: 300px;
  text-align: center;
  line-height: 1.5;
}
.detail-content {
  padding: 0;
}
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 5;
}
.detail-header h3 {
  font-size: 15px;
  font-weight: 700;
}
.detail-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* --- Detail Images --- */
.detail-images-section {
  display: flex;
  gap: 24px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-muted);
  overflow-x: auto;
}
.detail-images-group {
  min-width: 0;
}
.detail-images-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.detail-images-row {
  display: flex;
  gap: 8px;
}
.detail-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition:
    border-color 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
  flex-shrink: 0;
  background: white;
}
.detail-img:hover {
  border-color: var(--primary);
  transform: scale(1.04);
  box-shadow: var(--shadow-md);
}
.detail-img-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* --- Detail Grid (2 columns) --- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
}
.detail-col {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.detail-col:first-child {
  border-right: 1px solid var(--border-light);
}
.detail-section {
  margin-bottom: 16px;
}
.detail-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.detail-card {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.detail-card h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  margin-top: auto;
}
.page-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--primary);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Empty State & Spinner ---------- */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- (Legacy side panel removed — using detail-panel layout) ---------- */

/* --- Commercial row --- */
.commercial-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.field-group label {
  font-size: 11px;
  color: var(--text-muted);
}
.field-group input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
}

/* --- Category selects --- */
.category-selects {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.category-selects select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.category-selects select:hover {
  border-color: var(--primary);
}
.category-selects select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.12);
  outline: none;
}

/* --- Attribute grid --- */
.attr-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.attr-row {
}
.attr-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.attr-label .idx {
  color: var(--text-light);
  font-weight: 400;
  font-size: 10px;
}
.attr-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.attr-chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 14px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.attr-chip:hover {
  border-color: var(--primary);
  background: #f0f9ff;
}
.attr-chip.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* --- (Panel tabs removed — no longer needed) --- */

/* --- (Panel actions removed — buttons now in detail-header-actions) --- */

/* --- Search input in filters bar --- */
.filter-search input {
  min-width: 220px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.filter-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

/* --- Danger outline button (Delete Tag) --- */
.btn-danger-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-danger-outline:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}

/* --- Extra small button --- */
.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
}

/* --- (Panel images section removed — replaced by detail-images-section) --- */

/* ========================================== */
/*       CATEGORY BREAKDOWN INDICATOR         */
/* ========================================== */

.cb-container {
  display: flex;
  gap: 16px;
  min-height: 500px;
}

.cb-filters {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  overflow-y: auto;
  max-height: 80vh;
  font-size: 12px;
}
.cb-filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}
.cb-filters-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.cb-filter-actions {
  display: flex;
  gap: 4px;
}
.cb-sa-btn {
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.cb-sa-btn:hover {
  background: var(--primary-light);
}

.cb-filter-group {
  margin-bottom: 12px;
}
.cb-filter-group-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Popover filter button */
.cb-pop-container {
  position: relative;
  margin-bottom: 3px;
}
.cb-pop-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}
.cb-pop-btn:hover {
  border-color: var(--primary);
}
.cb-pop-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.cb-pop-dropdown {
  display: none;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
}
.cb-pop-dropdown.open {
  display: block;
}
.cb-pop-actions {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.cb-pop-actions button {
  padding: 2px 8px;
  font-size: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
}
.cb-pop-actions button:hover {
  background: var(--primary-light);
}
.cb-pop-list {
  padding: 4px 0;
}
.cb-pop-option {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 0;
}
.cb-pop-option:hover {
  background: var(--primary-light);
}
.cb-pop-option input[type='checkbox'] {
  accent-color: var(--primary);
}

/* Tree hierarchy */
.cb-tree-cat {
  margin-bottom: 4px;
}
.cb-tree-cat-header {
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 5px;
  font-size: 12px;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cb-tree-cat-header:hover {
  background: rgba(0, 0, 0, 0.04);
}
.cb-tree-arrow {
  font-size: 9px;
  color: var(--text-muted);
  width: 12px;
  display: inline-block;
  cursor: pointer;
}
.cb-tree-children {
  padding-left: 16px;
}
.cb-tree-sub {
  margin-bottom: 4px;
}
.cb-tree-sub-header {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 2px 4px;
  margin-bottom: 2px;
}
.cb-tree-sub-expandable {
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.1s;
}
.cb-tree-sub-expandable:hover {
  background: rgba(0, 0, 0, 0.03);
}
.cb-tree-sub-leaf {
  padding-left: 16px;
  color: var(--text-light);
  font-weight: 400;
}
.cb-tree-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex: 1;
}
.cb-tree-label input[type='checkbox'] {
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
}
/* Sortable column headers */
.cb-sortable {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.cb-sortable:hover {
  background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%) !important;
}
.cb-sort-arrow {
  font-size: 9px;
  color: var(--primary);
}

.cb-content {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.cb-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Side-by-side row: table + chart */
.cb-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}
.cb-card-half {
  flex: 1;
  min-width: 0;
}
.cb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.cb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.cb-card-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}
.cb-card-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.cb-card-controls label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.cb-card-controls select {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}
.cb-chart-wrap {
  padding: 12px;
  height: 320px;
  position: relative;
}
.cb-chart-wrap canvas {
  max-height: 100%;
}
.cb-table-wrap {
  max-height: 400px;
  overflow-y: auto;
}

/* ---- CB Styled Table ---- */
.cb-styled-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.cb-styled-table thead th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.cb-styled-table thead th.num-col {
  text-align: right;
}
.cb-styled-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
}
.cb-styled-table tbody td.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cb-th-toggle {
  width: 28px;
}

/* Category row (expandable) */
.cb-cat-row {
  cursor: pointer;
  background: var(--surface);
  transition: background 0.12s;
}
.cb-cat-row:hover {
  background: rgba(8, 145, 178, 0.04);
}
.cb-toggle-cell {
  width: 28px;
  text-align: center;
  color: var(--text-light);
  font-size: 11px;
  -webkit-user-select: none;
  user-select: none;
  transition: color 0.15s;
}
.cb-cat-row:hover .cb-toggle-cell {
  color: var(--primary);
}
.cb-cat-row.expanded {
  background: rgba(8, 145, 178, 0.06);
}
.cb-cat-row.expanded .cb-toggle-cell {
  color: var(--primary);
}

/* Subcategory row */
.cb-sub-row {
  background: #f8fafc;
}
.cb-sub-row:hover {
  background: #f0f4f8;
}
.cb-sub-name {
  padding-left: 20px !important;
  color: var(--text-muted);
  font-weight: 500;
}

/* Value row (global attrs table) */
.cb-val-row {
  background: var(--surface);
  transition: background 0.12s;
}
.cb-val-row:hover {
  background: rgba(8, 145, 178, 0.04);
}

@media (max-width: 1200px) {
  .cb-row {
    flex-direction: column;
  }
  .cb-container {
    flex-direction: column;
  }
  .cb-filters {
    width: 100%;
    max-height: none;
    min-width: 0;
  }
}

/* ---------- Batch Tagging Modal ---------- */
.batch-panel {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.batch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.batch-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.batch-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.batch-filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.batch-filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.batch-filter-row label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.batch-filter-row select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
}
.batch-multi-select {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
}
.batch-multi-select label {
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.batch-multi-select label:has(input:checked) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.batch-multi-select input[type='checkbox'] {
  display: none;
}
.batch-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.batch-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}
.batch-progress {
  margin-top: 14px;
}
.progress-bar-bg {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s;
}
.batch-progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  display: inline-block;
}
.batch-actions {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-save {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: white;
  border: 1px solid #047857;
}
.btn-save:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}
.btn-auto {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: white;
  border: 1px solid #0e7490;
}
.btn-auto:hover {
  background: linear-gradient(135deg, #0e7490 0%, #155e75 100%);
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.35);
}
.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg-muted);
}

.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  min-width: 200px;
}
.toast.success {
  background: var(--success-bg);
  color: var(--success);
  border-left: 3px solid var(--success);
}
.toast.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-left: 3px solid var(--danger);
}
.toast.info {
  background: #e0f2fe;
  color: #0369a1;
  border-left: 3px solid #0ea5e9;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Image Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: pointer;
}
.modal-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   EDA TAB
   ============================================================ */

.eda-container {
  padding: 24px 28px;
  overflow-y: auto;
  min-height: calc(100vh - 110px);
}

/* --- Summary Cards --- */
.eda-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.summary-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border-light);
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.summary-card-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.summary-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-top: 6px;
}

/* --- EDA Filters (hierarchical, collapsible) --- */
.eda-filters {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  border: 1px solid var(--border-light);
}
.eda-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
}
.eda-filters-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.eda-filters-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.eda-collapse-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
}
.eda-filters-body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition:
    max-height 0.3s ease,
    opacity 0.2s ease,
    padding 0.3s ease;
  overflow: hidden;
}
.eda-filters-body.collapsed {
  max-height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}
.eda-filter-section {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 14px 12px;
  background: var(--bg);
}
.eda-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.eda-specific-context {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-light);
  text-transform: none;
  letter-spacing: 0;
}
.eda-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.eda-hierarchy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.eda-filter-item {
  position: relative;
  min-width: 120px;
  flex: 0 0 auto;
}
.eda-filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.eda-filter-label:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.1);
  background: rgba(8, 145, 178, 0.03);
}
.eda-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  background: var(--bg);
  color: var(--text-light);
  transition:
    background 0.2s,
    color 0.2s;
}
.eda-filter-count.active {
  background: var(--primary);
  color: white;
}
.eda-filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 6px 0;
  margin-top: 3px;
}
.eda-filter-item.open .eda-filter-dropdown {
  display: block;
}
.eda-filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.eda-filter-option:hover {
  background: var(--primary-light);
}
.eda-filter-option input[type='checkbox'] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

/* --- EDA Charts --- */
.eda-charts {
  margin-bottom: 22px;
}
.eda-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.eda-chart-card {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  transition: box-shadow 0.2s;
}
.eda-chart-card:hover {
  box-shadow: var(--shadow-md);
}
.eda-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.eda-chart-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.eda-chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.eda-chart-controls select {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
}
.eda-chart-controls select:hover {
  border-color: var(--primary);
}
.eda-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.eda-toggle input[type='checkbox'] {
  accent-color: var(--primary);
  width: 13px;
  height: 13px;
}
.eda-radio-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.eda-radio {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-right: 1px solid var(--border);
  transition:
    background 0.15s,
    color 0.15s;
}
.eda-radio:last-child {
  border-right: none;
}
.eda-radio:has(input:checked) {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.eda-radio input[type='radio'] {
  display: none;
}
.btn-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}
.btn-info:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.1);
}
.eda-chart-card canvas {
  width: 100% !important;
  max-height: 240px !important;
}

/* --- Scatter brand filter chips --- */
.eda-scatter-brand-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.eda-brand-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.eda-brand-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.eda-brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 9px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: all 0.15s;
}
.eda-brand-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.eda-brand-chip:hover:not(.active) {
  border-color: var(--primary);
  background: rgba(8, 145, 178, 0.06);
}

/* --- EDA Aggregation / Drill-down Tables --- */
.eda-agg-section {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.eda-agg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.eda-agg-header h3 {
  font-size: 14px;
  font-weight: 700;
}
.eda-agg-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.eda-agg-controls select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
}
.eda-table-wrap {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}
.drill-th-toggle {
  width: 30px;
}
.eda-agg-section-gap {
  margin-top: 18px;
}

/* Drill-down table — entire row clickable */
.eda-drill-table .drill-row-cat,
.eda-drill-table .drill-row-sub {
  cursor: pointer;
  transition: background 0.12s;
}
.eda-drill-table .drill-row-cat:hover {
  background: rgba(8, 145, 178, 0.04);
}
.eda-drill-table .drill-row-sub:hover {
  background: rgba(8, 145, 178, 0.04);
}
.eda-drill-table .drill-toggle {
  width: 28px;
  text-align: center;
  color: var(--text-light);
  font-size: 11px;
  -webkit-user-select: none;
  user-select: none;
  transition: color 0.15s;
}
.eda-drill-table .drill-row-cat:hover .drill-toggle,
.eda-drill-table .drill-row-sub:hover .drill-toggle {
  color: var(--primary);
}
.eda-drill-table .drill-toggle.expanded {
  color: var(--primary);
}
.eda-drill-table .drill-row-cat {
  font-weight: 600;
  background: var(--surface);
}
.eda-drill-table .drill-row-sub {
  background: #f8fafc;
}
.eda-drill-table .drill-row-sub td:nth-child(2) {
  padding-left: 28px;
}
.eda-drill-table .drill-row-attr {
  background: #f1f5f9;
  font-size: 12px;
  color: var(--text-muted);
}
.eda-drill-table .drill-row-attr td:nth-child(2) {
  padding-left: 48px;
}
.eda-drill-table .drill-child {
  display: none;
}
.eda-drill-table .drill-child.visible {
  display: table-row;
}

/* --- Info panel overlay (larger, prettier) --- */
.eda-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: edaFadeIn 0.2s ease;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.eda-info-modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  max-width: 560px;
  width: 92%;
  padding: 28px 32px 24px;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
}
.eda-info-modal h4 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.eda-info-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-bottom: 14px;
}
.eda-info-section {
  margin-bottom: 16px;
}
.eda-info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 6px;
}
.eda-info-modal p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.eda-info-modal .katex-block {
  display: block;
  text-align: center;
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  overflow-x: auto;
}
.eda-info-modal .katex-inline {
  display: inline-block;
}
.eda-info-modal code {
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  color: var(--primary-dark);
}
.eda-info-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: var(--bg);
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
}
.eda-info-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
@keyframes edaFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Tag pills (EDA/Indicators) --- */
.tag-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 220px;
}
.tag-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  white-space: nowrap;
}
.tag-more {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
}

/* ============================================================
   INDICATORS TAB
   ============================================================ */

.indicators-container {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.indicators-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.indicators-selector label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.indicators-selector select {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  min-width: 280px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.indicators-selector select:hover {
  border-color: var(--primary);
}
.indicators-selector select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.12);
}

/* --- Indicator Description --- */
.indicator-description {
  margin-bottom: 12px;
}
.indicator-desc-card {
  background: linear-gradient(135deg, #f0f9ff, #ecfdf5);
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 14px 20px;
}
.indicator-desc-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.indicator-desc-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Indicator Controls (filters, modes) --- */
.indicator-controls {
  margin-bottom: 14px;
}
.ind-ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ind-ctrl-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.ind-ctrl-row select,
.ind-ctrl-row input[type='text'] {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  min-width: 160px;
}
.ind-ctrl-row select:focus,
.ind-ctrl-row input[type='text']:focus {
  border-color: var(--primary);
}
.ind-ctrl-row button,
.ind-btn {
  padding: 6px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.ind-ctrl-row button:hover,
.ind-btn:hover {
  background: var(--primary-hover);
}
.ind-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ind-mode-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--border);
}
.ind-mode-btn:last-child {
  border-right: none;
}
.ind-mode-btn.active {
  background: var(--primary);
  color: #fff;
}
.ind-mode-btn:hover:not(.active) {
  background: var(--bg-muted);
  color: var(--primary);
}

/* --- Indicator Content --- */
.indicator-content {
}

.indicator-chart-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
  height: 320px;
}
.indicator-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.indicator-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.indicator-table-wrap .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.indicator-table-wrap .data-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 12px;
  text-align: left;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.indicator-table-wrap .data-table th.num-col {
  text-align: right;
}
.indicator-table-wrap .data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.indicator-table-wrap .data-table td.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.indicator-table-wrap .data-table tbody tr {
  cursor: default;
  transition: background 0.1s;
}
.indicator-table-wrap .data-table tbody tr:hover {
  background: rgba(8, 145, 178, 0.04);
}
.indicator-table-wrap .data-table tbody tr:nth-child(even) {
  background: var(--bg-muted);
}
.indicator-table-wrap .data-table tbody tr:nth-child(even):hover {
  background: rgba(8, 145, 178, 0.06);
}
.indicator-table-wrap .data-table tbody tr:last-child td {
  border-bottom: none;
}
/* Row rank number */
.indicator-table-wrap .rank-cell {
  font-weight: 700;
  color: var(--text-light);
  font-size: 11px;
  width: 32px;
  text-align: center;
}
/* Revenue bar inside table cell */
.ind-rev-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ind-rev-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--primary);
  opacity: 0.6;
  min-width: 4px;
}
.ind-rev-val {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Penetration bar */
.ind-pct-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}
.ind-pct-bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.ind-pct-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.3s;
}
.ind-pct-label {
  font-size: 11px;
  white-space: nowrap;
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Section card wrapper for tables with titles */
.ind-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.ind-section-card-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ind-section-card-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.ind-section-card-header .ind-section-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
}
.ind-section-card .indicator-table-wrap {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
}
/* Methodology / description hints */
.ind-methodology {
  background: linear-gradient(135deg, #f0f9ff, #ecfdf5);
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.ind-methodology strong {
  color: var(--text);
  font-weight: 700;
}
.ind-methodology code {
  background: rgba(8, 145, 178, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--primary-dark);
}
/* Quadrant badge colors */
.quad-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.quad-star {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.quad-premium {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}
.quad-volume {
  background: #cffafe;
  color: #155e75;
  border: 1px solid #67e8f9;
}
.quad-under {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* --- Indicator Stat Row --- */
.indicator-stat-row {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.indicator-stat {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 20px;
  flex: 1;
  min-width: 120px;
  text-align: center;
}
.indicator-stat-val {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}
.indicator-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Section titles & hints --- */
.indicator-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.indicator-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-style: italic;
  padding: 8px 12px;
  background: var(--bg-muted);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- Price Analysis: Category cards --- */
.price-cat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.price-cat-card h4 {
  font-size: 14px;
  font-weight: 600;
  padding: 12px 16px 8px;
  color: var(--text);
}
.price-cat-meta {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}
.highlight-row {
  background: #ecfdf5 !important;
}
.highlight-row td:first-child {
  font-weight: 700;
}

/* =========================================================
   SIMILARITY INDICATOR — Complete Styles
   ========================================================= */

/* --- Similarity badges --- */
.sim-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.sim-badge.sim-high {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.sim-badge.sim-mid {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.sim-badge.sim-low {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* --- Percentage variation badges --- */
.sim-pct-up {
  color: #059669;
  font-size: 11px;
  font-weight: 700;
}
.sim-pct-down {
  color: #dc2626;
  font-size: 11px;
  font-weight: 700;
}
.sim-pct-neutral {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

/* Legacy diff badges (kept for compatibility) */
.sim-diff-up {
  color: #059669;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}
.sim-diff-down {
  color: #dc2626;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}

/* =========================================================
   Controls Panel
   ========================================================= */
.sim-controls-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.sim-controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--border);
}
.sim-controls-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.sim-controls-body {
  padding: 16px 20px;
}
.sim-mode-section {
  display: none;
}
.sim-mode-section.active {
  display: block;
}
.sim-mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sim-mode-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Inline row — all controls in a single horizontal line */
.sim-inline-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.sim-ctrl-sep {
  width: 1px;
  height: 32px;
  background: var(--border);
  align-self: flex-end;
  margin: 0 4px;
  flex-shrink: 0;
}

/* Control grid (legacy, keep for other uses) */
.sim-ctrl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.sim-ctrl-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.sim-ctrl-grow {
  flex: 0 1 260px;
  min-width: 140px;
}
.sim-ctrl-inline-label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.sim-ctrl-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sim-ctrl-field select,
.sim-ctrl-field input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.sim-ctrl-field textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--card-bg);
  color: var(--text);
  font-family: var(--font);
  resize: vertical;
  transition: border-color 0.15s;
}
.sim-ctrl-field select:focus,
.sim-ctrl-field input:focus,
.sim-ctrl-field textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}
.sim-ctrl-small {
  max-width: 90px;
  flex-shrink: 0;
}
.sim-ctrl-action {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}

/* Group mode header row */
.sim-group-header-row {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
/* ID list row */
.sim-ids-row {
  align-items: flex-end;
}
.sim-ids-row .sim-ctrl-grow {
  flex: 1;
  min-width: 200px;
}

/* =========================================================
   Similarity Card (generic wrapper)
   ========================================================= */
.sim-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.sim-card-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sim-card-body {
  padding: 16px;
}

/* =========================================================
   Similarity Target Card
   ========================================================= */
.sim-target-card {
  background: #f0f7ff;
  border: 1px solid #93c5fd;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.sim-target-img {
  flex-shrink: 0;
}
.sim-target-img img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #93c5fd;
}
.sim-target-body {
  flex: 1;
  min-width: 0;
}
.sim-target-card h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.sim-target-info {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.sim-target-attrs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.sim-attr-group {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
}
.sim-attr-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
}

/* =========================================================
   Attribute Chips
   ========================================================= */
.sim-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 500;
  margin: 2px 2px;
}
.sim-chip b {
  font-weight: 700;
}
.sim-chip-shared {
  background: #dcfce7;
  color: #166534;
}
.sim-chip-diff {
  background: #fee2e2;
  color: #991b1b;
}
.sim-chip-only-a {
  background: #dbeafe;
  color: #1e40af;
}
.sim-chip-only-b {
  background: #fef3c7;
  color: #92400e;
}
.sim-chip-more {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}
.sim-attrs-cell {
  max-width: 300px;
  line-height: 1.8;
}

/* =========================================================
   Styled Table (replaces old .sim-table)
   ========================================================= */
.sim-styled-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.sim-styled-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.sim-styled-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.sim-styled-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}
.sim-styled-table tbody tr:hover {
  background: #f0f9ff;
}
.sim-styled-table tbody tr:last-child td {
  border-bottom: none;
}

/* Thumbnails in table */
.sim-thumb-cell {
  width: 48px;
  padding: 6px !important;
}
.sim-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.sim-thumb-none {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 10px;
}

/* Legacy sim-table kept for compat */
.sim-results-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}
.sim-table {
  font-size: 12px;
}
.sim-row {
  cursor: pointer;
  transition: background 0.12s;
}
.sim-row:hover {
  background: #f0f9ff !important;
}

/* =========================================================
   Chart Panels
   ========================================================= */
.sim-chart-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.sim-chart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--border);
}
.sim-chart-panel-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.sim-chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sim-radio {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.sim-radio input[type='radio'] {
  margin: 0;
  accent-color: var(--primary);
}
.sim-chart-desc {
  padding: 10px 18px 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.sim-chart-wrap {
  height: 280px;
  position: relative;
  padding: 12px 18px 16px;
}
.sim-chart-insight {
  padding: 10px 18px 14px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}
.sim-chart-insight strong {
  color: var(--text);
}

/* Old charts grid (kept for backwards compat) */
.sim-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.sim-chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.sim-chart-card h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}

/* =========================================================
   Top-10 Gallery (Attribute Overlap chart)
   ========================================================= */
.sim-top10-gallery {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  overflow-x: auto;
  border-bottom: 1px solid #f1f5f9;
}
.sim-gallery-item {
  flex-shrink: 0;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
}
.sim-gallery-item:hover {
  transform: scale(1.05);
}
.sim-gallery-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: block;
  margin-bottom: 3px;
}
.sim-gallery-item span {
  font-size: 9px;
  color: var(--text-muted);
  display: block;
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sim-gallery-sim {
  font-size: 9px;
  font-weight: 700;
  color: var(--primary);
}
.sim-gallery-copied {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #059669;
  color: #fff;
  font-size: 8px;
  padding: 1px 5px;
  border-radius: 8px;
  animation: simFadeOut 1.2s forwards;
}
@keyframes simFadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.sim-gallery-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 10px;
  margin-bottom: 3px;
}

/* =========================================================
   Rankings Grid
   ========================================================= */
.sim-rank-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* =========================================================
   Detail Side Panel
   ========================================================= */
.sim-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 900;
}
.sim-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 92vw);
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.15);
  z-index: 910;
  overflow-y: auto;
  padding: 24px;
  animation: simSlideIn 0.2s ease;
}
@keyframes simSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}
.sim-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sim-detail-header h3 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
}
.sim-detail-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}
.sim-detail-close:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* Detail: VS comparison */
.sim-detail-vs {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: linear-gradient(135deg, #eff6ff, #fffbeb);
  border-radius: var(--radius);
  border: 1px solid #e2e8f0;
}
.sim-detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.sim-detail-item strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sim-detail-vs-badge {
  text-align: center;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.sim-detail-vs-badge .sim-badge {
  font-size: 16px;
  padding: 4px 14px;
}
.sim-detail-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
}
.sim-detail-item-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-bottom: 16px;
  background: #f0f9ff;
  border-radius: var(--radius);
  border: 1px solid #bae6fd;
  font-size: 12px;
}

/* Detail: Sections */
.sim-detail-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.sim-detail-section:last-child {
  border-bottom: none;
}
.sim-detail-section h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.sim-detail-section p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 8px 0;
}
.sim-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.sim-detail-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}
.sim-detail-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.sim-detail-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
}

/* Detail: Contextual insight boxes */
.sim-detail-insight {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.7;
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.sim-detail-insight::before {
  flex-shrink: 0;
  font-size: 14px;
}
.sim-insight-warn {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
}
.sim-insight-warn::before {
  content: '⚠️';
}
.sim-insight-ok {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}
.sim-insight-ok::before {
  content: '✅';
}

/* =========================================================
   Matrix Heatmap
   ========================================================= */
.sim-matrix-container {
  overflow: auto;
  max-height: 600px;
  padding: 8px;
}
.sim-matrix {
  display: inline-block;
}
.sim-matrix-label-top {
  font-size: 8px;
  color: var(--text-muted);
  writing-mode: vertical-lr;
  text-align: right;
  height: 60px;
  overflow: hidden;
}
.sim-matrix-label {
  font-size: 10px;
  color: var(--text);
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.sim-matrix-row {
  display: flex;
}
.sim-matrix-cell {
  cursor: pointer;
  transition: opacity 0.1s;
  border: 0.5px solid rgba(255, 255, 255, 0.3);
}
.sim-matrix-cell:hover {
  opacity: 0.7;
  outline: 2px solid var(--primary);
  z-index: 1;
}
.sim-matrix-legend {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  font-size: 10px;
  color: var(--text-muted);
}

/* =========================================================
   Gap Pill
   ========================================================= */
.gap-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  white-space: nowrap;
  margin: 1px 2px;
}

/* =========================================================
   BRAND CANNIBALIZATION — Styles
   ========================================================= */

/* Methodology Info */
.can-methodology {
  margin-bottom: 16px;
}
/* Compact cannibalization controls */
.can-ctrl-compact {
  flex: 0 1 auto;
  min-width: 0;
}
.can-ctrl-compact select {
  min-width: 120px;
  max-width: 200px;
}
.can-methodology details {
  background: var(--bg-muted);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.can-methodology summary {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.can-methodology summary:hover {
  color: var(--primary);
}
.can-methodology-body {
  padding: 4px 16px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.can-methodology-body p {
  margin: 0 0 8px;
}
.can-methodology-body code {
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* Brand Profiles Grid */
.can-profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}

/* Profile Card */
.can-profile-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.can-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid var(--border);
}
.can-profile-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.can-profile-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}
.can-profile-risk {
  text-align: right;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}
.can-profile-risk small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Profile sections */
.can-profile-section {
  padding: 12px 20px;
  border-bottom: 1px solid #f1f5f9;
}
.can-profile-section h5 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.can-profile-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 0;
  line-height: 1.5;
}

/* Competitor list */
.can-compete-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.can-compete-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}

/* Strategy box */
.can-profile-strategy {
  padding: 14px 20px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  background: #fffbeb;
  border-top: 1px solid #fcd34d40;
  flex: 1;
}
.can-profile-strategy strong {
  color: var(--text);
}

/* Garment pairs in detail panel */
.can-garment-pairs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.can-garment-pair {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.can-garment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 12px;
}
.can-garment-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.can-garment-sim {
  flex-shrink: 0;
  text-align: center;
}

/* --- Charts grid for multi-chart indicators --- */
.ind-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.ind-chart-grid .indicator-chart-wrap {
  margin-bottom: 0;
  height: 280px;
}
.ind-chart-grid .indicator-chart-wrap h5 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- View tabs within an indicator --- */
.ind-view-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.ind-view-tab {
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.ind-view-tab:hover {
  color: var(--text);
}
.ind-view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.ind-view-panel {
  display: none;
}
.ind-view-panel.active {
  display: block;
}

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

@media (max-width: 900px) {
  .eda-chart-row {
    grid-template-columns: 1fr;
  }
  .ind-chart-grid {
    grid-template-columns: 1fr;
  }
  .tab-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  .indicator-stat-row {
    flex-direction: column;
  }
  .sim-charts-grid {
    grid-template-columns: 1fr;
  }
  .sim-rank-grid {
    grid-template-columns: 1fr;
  }
  .sim-detail-panel {
    width: 100vw;
  }
}

@media (max-width: 700px) {
  .header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .tagging-layout {
    flex-direction: column;
    height: auto;
  }
  .instance-list-panel {
    width: 100%;
    min-width: 0;
    max-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .detail-col:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }
  .eda-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .tab-bar {
    overflow-x: auto;
  }
  .tab-bar-right {
    flex-shrink: 0;
  }
}
