/* 8tribute Admin UI — Styles (Phase 7) */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --success: #22c55e;
  --success-bg: #dcfce7;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* =============================================================================
   LOGIN
   ============================================================================= */

#login-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

#login-overlay[hidden] {
  display: none;
}

.login-card {
  background: var(--surface);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.error-msg {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--error-bg);
  color: var(--error);
  border-radius: var(--radius);
  font-size: 13px;
}

/* =============================================================================
   HEADER
   ============================================================================= */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.version {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 12px;
}

.header-center {
  display: flex;
  align-items: center;
}

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

.user-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* =============================================================================
   ORG SWITCHER
   ============================================================================= */

.org-switcher {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 200px;
}

.org-switcher:focus {
  outline: none;
  border-color: var(--primary);
}

/* =============================================================================
   NAVIGATION TABS
   ============================================================================= */

#main-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  padding-top: 16px;
}

.nav-group {
  display: flex;
  gap: 4px;
  position: relative;
}

.nav-group::before {
  content: attr(data-group-label);
  position: absolute;
  top: -14px;
  left: 4px;
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.nav-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
  align-self: center;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.tab-btn[hidden] {
  display: none;
}

/* =============================================================================
   STATUS INDICATOR
   ============================================================================= */

.status-indicator {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-indicator.healthy {
  background: var(--success-bg);
  color: #166534;
}

.status-indicator.unhealthy {
  background: var(--error-bg);
  color: #991b1b;
}

/* =============================================================================
   CONTENT AREA
   ============================================================================= */

#content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-content {
  display: none;
}

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

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 32px 0;
}

/* =============================================================================
   CARDS & DASHBOARD
   ============================================================================= */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.card p {
  margin: 4px 0;
  font-size: 14px;
}

.status-healthy {
  color: var(--success);
  font-weight: 600;
}

.status-unhealthy {
  color: var(--error);
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
}

.btn-icon {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-size: 14px;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

/* =============================================================================
   DATA TABLE
   ============================================================================= */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

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

.data-table tr:hover td {
  background: #f8fafc;
}

.data-table .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* =============================================================================
   BADGES
   ============================================================================= */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-active {
  background: var(--success-bg);
  color: #166534;
}

.badge-inactive {
  background: var(--bg);
  color: var(--text-muted);
}

.badge-expired {
  background: var(--bg);
  color: var(--text-muted);
}

.badge-used {
  background: var(--warning-bg);
  color: #92400e;
}

.badge-role {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-system_admin {
  background: #fce7f3;
  color: #9d174d;
}

.badge-org_admin {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-org_user {
  background: var(--bg);
  color: var(--text-secondary);
}

.badge-gb_admin {
  background: var(--warning-bg);
  color: #92400e;
}

/* =============================================================================
   FORMS
   ============================================================================= */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.checkbox-item:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
}

.checkbox-item input[type="checkbox"] {
  margin: 0;
}

/* NACE Picker — collapsible grouped sections */

.nace-picker {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
}

.nace-section {
  border-bottom: 1px solid var(--border);
}

.nace-section:last-child {
  border-bottom: none;
}

.nace-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.nace-section-header:hover {
  background: var(--bg);
}

.nace-toggle {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.nace-section.open .nace-toggle {
  transform: rotate(90deg);
}

.nace-section-label {
  border: none;
  padding: 0;
  font-size: 13px;
  flex: 1;
  pointer-events: auto;
}

.nace-section-label:has(input:checked) {
  background: none;
  border-color: transparent;
}

.nace-divisions {
  display: none;
  padding: 2px 10px 8px 30px;
}

.nace-section.open .nace-divisions {
  display: block;
}

.nace-division-item {
  padding: 3px 8px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  margin-bottom: 2px;
}

.nace-division-item:has(input:checked) {
  background: var(--primary-light);
}

.nace-div-code {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 20px;
  display: inline-block;
}

/* =============================================================================
   MODAL
   ============================================================================= */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* =============================================================================
   INFO BANNER
   ============================================================================= */

.info-banner {
  padding: 12px 16px;
  background: var(--info-bg);
  color: #1e40af;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

.info-banner[hidden] {
  display: none;
}

/* =============================================================================
   STATES
   ============================================================================= */

.loading-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 14px;
  margin-top: 8px;
}

.data-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  color: white;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform 0.3s ease;
  max-width: 400px;
}

.toast.show {
  transform: translateX(0);
}

.toast-info {
  background: var(--info);
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--error);
}

.toast-warning {
  background: var(--warning);
  color: var(--text);
}

/* =============================================================================
   UTILITY
   ============================================================================= */

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: 13px;
}

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

.code-block {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  user-select: all;
  border: 1px solid var(--border);
  word-break: break-all;
}

/* =============================================================================
   FILTER BAR (Phase 7)
   ============================================================================= */

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.tab-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* =============================================================================
   KEYWORD EDITOR (Phase 7)
   ============================================================================= */

.keyword-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.keyword-tag .weight {
  font-size: 10px;
  color: var(--text-muted);
}

.keyword-tag .remove {
  cursor: pointer;
  color: var(--text-muted);
  margin-left: 2px;
  font-weight: 700;
}

.keyword-tag .remove:hover {
  color: var(--error);
}

.keyword-input {
  border: none;
  outline: none;
  font-size: 13px;
  padding: 4px;
  flex: 1;
  min-width: 120px;
  background: transparent;
}

/* =============================================================================
   ALLOWED MATRIX VIEW (Phase 7)
   ============================================================================= */

.matrix-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.matrix-row:last-of-type {
  border-bottom: none;
}

.matrix-ding {
  min-width: 160px;
  flex-shrink: 0;
}

.matrix-tuns {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.matrix-tun-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--success-bg);
  color: #166534;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* =============================================================================
   UPLOAD PROGRESS (Phase 7)
   ============================================================================= */

.upload-progress {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.upload-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  min-height: 20px;
}

/* =============================================================================
   DOCUMENT STATUS BADGES (Phase 7)
   ============================================================================= */

.badge-pending {
  background: var(--warning-bg);
  color: #92400e;
}

.badge-extracting,
.badge-processing {
  background: var(--info-bg);
  color: #1e40af;
  animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.badge-completed,
.badge-processed {
  background: var(--success-bg);
  color: #166534;
}

.badge-error {
  background: var(--error-bg);
  color: #991b1b;
}

.badge-danger {
  background: #fef2f2;
  color: #991b1b;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-deleted {
  background: var(--bg);
  color: var(--text-muted);
}

/* =============================================================================
   CONFIDENCE INDICATORS (Phase 7)
   ============================================================================= */

.confidence-high {
  background: var(--success-bg);
  color: #166534;
}

.confidence-medium {
  background: var(--warning-bg);
  color: #92400e;
}

.confidence-low {
  background: var(--error-bg);
  color: #991b1b;
}

/* =============================================================================
   REVIEW PANEL (Phase 7)
   ============================================================================= */

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.scope-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.4;
}

/* =============================================================================
   LEARNING KEYWORDS (Phase 7)
   ============================================================================= */

.learning-keyword {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  margin: 1px;
}

.learning-keyword.added {
  background: var(--success-bg);
  color: #166534;
}

.learning-keyword.confirmed {
  background: var(--info-bg);
  color: #1e40af;
}

.learning-keyword.excluded {
  background: var(--error-bg);
  color: #991b1b;
}

/* =============================================================================
   LEARNING PIPELINE — SUGGESTIONS (Phase 9)
   ============================================================================= */

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

.badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 4px;
  vertical-align: middle;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.suggestion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.suggestion-card { cursor: pointer; }
.suggestion-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.suggestion-card.positive { border-left: 4px solid var(--success); }
.suggestion-card.negative { border-left: 4px solid var(--error); }

.suggestion-checkbox { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; accent-color: var(--primary); }

.bulk-action-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--primary-light); border: 1px solid var(--primary); border-radius: var(--radius);
  margin-bottom: 12px; flex-wrap: wrap;
}
.bulk-action-bar span { font-size: 13px; font-weight: 600; color: var(--primary); }

.suggestion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.suggestion-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.suggestion-type.add { background: var(--success-bg); color: #166534; }
.suggestion-type.exclude { background: var(--error-bg); color: #991b1b; }

.suggestion-score {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.suggestion-score.score-high { color: #166534; }
.suggestion-score.score-medium { color: #92400e; }
.suggestion-score.score-low { color: #991b1b; }

.suggestion-keyword {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  margin: 4px 0;
  color: var(--text);
}

.suggestion-target {
  font-size: 13px;
  color: var(--text-secondary);
}

.suggestion-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.suggestion-evidence {
  margin-top: 8px;
}
.suggestion-evidence summary {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.suggestion-evidence .evidence-item {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.suggestion-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}

/* =============================================================================
   WIDER MODALS (Phase 7)
   ============================================================================= */

.modal-card.modal-wide {
  max-width: 720px;
}

.modal-card.modal-xl {
  max-width: 900px;
}

/* =============================================================================
   ELEMENT EDITOR (Phase 8)
   ============================================================================= */

/* Filter buttons row */
.element-filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.element-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.element-filter-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.element-filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.element-filter-btn .count {
  font-size: 11px;
  opacity: 0.8;
}

/* Stats bar */
.elem-stats-banner {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.elem-stats-banner strong {
  color: var(--text);
}

.elem-stats-separator {
  border-left: 1px solid var(--border);
  margin: 0 2px;
}

/* Element card list */
.element-card-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Element card */
.element-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.element-card:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.element-card:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.element-card:only-child {
  border-radius: var(--radius);
}

.element-card:hover {
  background: #f1f5f9;
}

.element-card.expanded {
  background: var(--primary-light);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.element-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.element-card-icon.figure {
  background: #fef3c7;
  color: #92400e;
}

.element-card-body {
  min-width: 0;
}

.element-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.semantic-type-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

.element-card-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.element-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.element-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.element-card-confidence {
  font-size: 13px;
  font-weight: 600;
}

.element-card-status {
  font-size: 11px;
  color: var(--text-muted);
}

/* Attribute badges */
.attr-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.attr-badge-ding {
  background: #ede9fe;
  color: #5b21b6;
}

.attr-badge-tun {
  background: #e0f2fe;
  color: #075985;
}

.attr-badge-topic {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.attr-badge-action {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.attr-badge-tag {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.attr-badge-process {
  background: #ecfdf5;
  color: #065f46;
}

/* Editable badge styles (inline ×/+ on cards) */
.attr-badge-editable {
  position: relative;
  padding-right: 4px;
  cursor: default;
  transition: padding-right 0.15s;
}
.attr-badge-editable:hover {
  padding-right: 18px;
}
.badge-remove-btn {
  display: none;
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 2px;
  font-weight: 700;
}
.badge-remove-btn:hover {
  opacity: 1;
  color: var(--error, #dc2626);
}
.attr-badge-editable:hover .badge-remove-btn {
  display: inline-block;
}
.badge-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px dashed var(--border, #cbd5e1);
  background: none;
  color: var(--text-secondary, #64748b);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.15s;
  flex-shrink: 0;
}
.badge-add-btn:hover {
  border-color: var(--primary, #6366f1);
  color: var(--primary, #6366f1);
  background: var(--primary-bg, #eef2ff);
}

/* Badge add dropdown */
.badge-add-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 220px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}
.badge-add-search {
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-size: 13px;
  outline: none;
  border-radius: 8px 8px 0 0;
  background: var(--surface, #fff);
}
.badge-add-list {
  overflow-y: auto;
  max-height: 260px;
  padding: 4px 0;
}
.badge-add-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  padding: 6px 10px 2px;
  letter-spacing: 0.5px;
}
.badge-add-item {
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.badge-add-item:hover {
  background: var(--hover-bg, #f1f5f9);
}
.badge-add-form {
  padding: 10px;
}
.badge-add-type-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.badge-type-option {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.badge-type-option input[type="radio"] {
  display: none;
}
.badge-type-option input[type="radio"]:checked + .attr-badge {
  outline: 2px solid var(--primary, #6366f1);
  outline-offset: 1px;
}

/* Inline editor panel */
.element-editor-panel {
  background: var(--surface);
  border: 1px solid var(--primary);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px;
  margin-bottom: 8px;
}

/* Title row with edit button */
.editor-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-title-row h4 {
  margin: 0;
  flex: 1;
  min-width: 0;
}

/* Text content with edit button */
.element-editor-text-row {
  margin-bottom: 16px;
}

.element-editor-text-row .element-editor-text {
  margin-bottom: 8px;
}

.element-editor-text {
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* Assigned attributes summary */
.assigned-attrs-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.assigned-attrs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.assigned-attrs-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 40px;
}

/* Collapsible attribute editing */
.attr-edit-details {
  margin-bottom: 16px;
}

.attr-edit-summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  padding: 8px 0;
  user-select: none;
  list-style: none;
}

.attr-edit-summary::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  transition: transform 0.2s;
}

.attr-edit-details[open] > .attr-edit-summary::before {
  transform: rotate(90deg);
}

.attr-edit-summary::-webkit-details-marker {
  display: none;
}

.element-editor-grid {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: 20px;
  margin-bottom: 16px;
  margin-top: 12px;
}

.element-editor-grid .checkbox-list {
  max-height: none;
  overflow-y: visible;
}

.checkbox-list.tun-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 12px;
  flex-direction: unset;
}

.element-editor-grid h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.element-editor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Figure thumbnail */
.figure-thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.figure-thumbnail-lg {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.figure-thumbnail-lg.clickable-image {
  cursor: zoom-in;
  transition: opacity 0.2s;
}

.figure-thumbnail-lg.clickable-image:hover {
  opacity: 0.9;
}

/* Load more */
.load-more-bar {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* Review indicator icons */
.status-icon-review {
  color: var(--warning);
}

.status-icon-checked {
  color: var(--success);
}

.status-icon-deleted {
  color: var(--error);
}

/* =============================================================================
   LINKED ELEMENTS (Phase 7+.8)
   ============================================================================= */

.linked-elements-section {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.linked-elements-section h5 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.linked-element-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.linked-element-item:hover {
  background: var(--bg);
}

.linked-element-item:last-child {
  border-bottom: none;
}

.seq-child-item.dragging {
  opacity: 0.4;
}

.seq-child-item.drag-over {
  border-top: 2px solid var(--primary);
}

.linked-figure-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.linked-element-info {
  flex: 1;
  min-width: 0;
}

.linked-element-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linked-element-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.unlink-btn {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.unlink-btn:hover {
  background: var(--error-bg);
}

.link-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 6px 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.link-add-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Link figure dialog */
.link-fig-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.link-fig-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-search-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.link-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.link-fig-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.link-fig-filter {
  font-size: 13px;
}

/* Figure selection grid */
.figure-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.figure-selection-item {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.figure-selection-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.figure-selection-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.figure-selection-img {
  width: 100%;
  height: 85px;
  background-color: #f3f4f6;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.figure-selection-title {
  padding: 5px 6px;
  font-size: 11px;
  text-align: center;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-search-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* --- Text selection list (for Text-Link dialog) --- */
.text-selection-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.text-selection-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.text-selection-item:last-child { border-bottom: none; }
.text-selection-item:hover { background: var(--primary-light); }
.text-selection-item.selected {
  background: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}

.text-selection-page {
  flex-shrink: 0;
  width: 36px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 2px;
}

.text-selection-body { flex: 1; min-width: 0; }

.text-selection-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-selection-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

/* =============================================================================
   BOUNDING BOX EDITOR (Phase 8.2)
   ============================================================================= */

.bbox-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bbox-editor-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.bbox-editor-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.bbox-editor-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.bbox-page-selector {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
}

.bbox-page-selector select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--surface);
  cursor: pointer;
}

.bbox-page-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.bbox-editor-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  min-height: 300px;
}

.bbox-editor-loading {
  color: var(--text-muted);
  font-size: 14px;
}

.bbox-canvas-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
  user-select: none;
}

.bbox-canvas-wrapper img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.bbox-rect {
  position: absolute;
  border: 3px solid var(--primary);
  background: rgba(37, 99, 235, 0.15);
  cursor: move;
  z-index: 5;
}

.bbox-rect.dragging {
  cursor: grabbing;
  border-color: var(--primary-dark);
  background: rgba(37, 99, 235, 0.25);
}

.bbox-rect.resizing {
  border-color: var(--primary-dark);
}

.bbox-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 2px;
  z-index: 10;
}

.bbox-handle:hover {
  background: var(--primary-light);
  border-color: var(--primary-dark);
}

.bbox-handle.nw {
  top: -6px;
  left: -6px;
  cursor: nw-resize;
}

.bbox-handle.ne {
  top: -6px;
  right: -6px;
  cursor: ne-resize;
}

.bbox-handle.sw {
  bottom: -6px;
  left: -6px;
  cursor: sw-resize;
}

.bbox-handle.se {
  bottom: -6px;
  right: -6px;
  cursor: se-resize;
}

.bbox-handle.n {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: n-resize;
}

.bbox-handle.s {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  cursor: s-resize;
}

.bbox-handle.w {
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
  cursor: w-resize;
}

.bbox-handle.e {
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
  cursor: e-resize;
}

.bbox-editor-controls {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.bbox-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bbox-input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.bbox-input-group input {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
  text-align: right;
}

.bbox-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* =============================================================================
   MATRIX VIEW (Phase 7+.4) — DING×TUN Grid
   ============================================================================= */

.matrix-grid-wrapper {
  overflow: auto;
  max-height: 65vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}

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

.matrix-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  border-bottom: 2px solid var(--border);
  padding: 0;
}

.matrix-corner {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 140px;
  background: var(--surface);
}

.matrix-header-cell {
  min-width: 56px;
  max-width: 80px;
  height: 100px;
  vertical-align: bottom;
  padding: 4px 2px 8px 2px;
  text-align: center;
}

.matrix-header-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 90px;
}

.matrix-row-header {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-right: 2px solid var(--border);
  min-width: 140px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-cell {
  min-width: 56px;
  height: 48px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.matrix-cell:hover {
  transform: scale(1.15);
  z-index: 5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.matrix-cell-selected {
  outline: 3px solid var(--primary);
  outline-offset: -1px;
  z-index: 4;
}

/* Cell color levels */
.cell-empty {
  background: var(--bg);
  color: var(--text-muted);
}

.cell-low {
  background: #dcfce7;
  color: #166534;
}

.cell-medium {
  background: #86efac;
  color: #14532d;
}

.cell-high {
  background: #4ade80;
  color: #052e16;
}

.cell-very-high {
  background: #22c55e;
  color: white;
}

.cell-not-allowed {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    var(--border) 3px,
    var(--border) 4px
  );
  color: var(--text-muted);
  font-size: 11px;
  cursor: default;
}

/* Matrix stats bar */
.stat-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.stat-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.stat-good { color: #166534; }
.stat-warn { color: #92400e; }
.stat-bad { color: #991b1b; }

/* Cell detail panel (sidebar) */
.matrix-cell-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.matrix-cell-panel[hidden] {
  display: none;
}

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

.matrix-cell-panel-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

#matrix-cell-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.cell-panel-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.cell-panel-actions {
  margin-bottom: 16px;
}

.cell-panel-more {
  text-align: center;
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Cell element cards */
.cell-elements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cell-element-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.cell-element-child {
  margin-left: 32px;
  border-left: 2px solid var(--primary-light, #93c5fd);
  background: var(--bg-secondary, #f8fafc);
  opacity: 0.9;
}

.cell-element-icon {
  flex-shrink: 0;
  font-size: 16px;
  padding-top: 2px;
}

.cell-element-body {
  flex: 1;
  min-width: 0;
}

.cell-element-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-element-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  font-size: 12px;
}

.cell-element-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge-sm {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
}

/* =============================================================================
   BUNDLE CARDS (Phase 7+.6)
   ============================================================================= */

.bundle-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bundle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

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

.bundle-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.bundle-card-name-input {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  width: 100%;
}

.bundle-card-count {
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.bundle-elements-preview {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bundle-elements-preview li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bundle-elements-more {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 2px 0;
}

.bundle-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.bundle-generating {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary);
}

.bundle-generating .spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================================================
   MATRIX DRILL-DOWN NAVIGATION
   ============================================================================= */

.matrix-nav-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.btn-back:hover {
  background: var(--bg);
}

.matrix-breadcrumb {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Bundle Tiles (Level 2) */

.bundle-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 16px 16px;
}

.bundle-tile {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-align: center;
}

.bundle-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.bundle-tile h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--text);
}

.bundle-tiles-actions {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* Element list within drill-down */

.cell-elements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px;
}

.cell-panel-info {
  padding: 8px 16px 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Bundle overlay toggle */

.matrix-overlay-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.matrix-overlay-toggle:hover {
  background: var(--bg);
}

.matrix-overlay-toggle input[type="checkbox"] {
  margin: 0;
}

/* Bundled header highlighting */

.matrix-bundled-header {
  background: var(--primary-light) !important;
  font-style: italic;
}

/* Compact stats line */

.matrix-stats-line {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 10px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  align-items: center;
  letter-spacing: 0.2px;
}

.matrix-stats-line strong {
  color: var(--text);
  margin-right: 4px;
}

.matrix-stats-text {
  flex: 1;
}

/* Push notification admin */

.push-notify-btn {
  margin-left: auto;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
  flex-shrink: 0;
}

.push-notify-btn:hover {
  color: var(--primary);
}

.push-search-container {
  position: relative;
}

.push-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

.push-search-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.push-search-item:last-child {
  border-bottom: none;
}

.push-search-item:hover {
  background: var(--primary-light);
}

.push-search-icon {
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 2px;
}

.push-search-info {
  min-width: 0;
}

.push-search-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.push-search-preview {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.push-search-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.push-selected-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}

.push-remove-source {
  font-size: 14px;
  padding: 0 2px;
  color: var(--text-muted);
}

.push-remove-source:hover {
  color: var(--error);
}

.push-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.push-preview-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.push-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.push-preview-body {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Bundle generation status */

.bundle-status-ok {
  font-size: 12px;
  color: var(--success);
}

.bundle-status-action {
  font-size: 12px;
  color: var(--warning);
  text-decoration: underline;
  cursor: pointer;
}

.bundle-status-action:hover {
  color: var(--error);
}

.bundle-status-generating {
  font-size: 12px;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bundle-status-error {
  font-size: 12px;
  color: var(--error);
}

.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border: 1px solid var(--warning);
  font-weight: 500;
}

.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
}

.ab-validation-hint {
  font-size: 0.8rem;
  color: #92400e;
  margin-top: 4px;
}

/* =============================================================================
   ATTRIBUTE BUNDLES ADMIN (Phase 5)
   ============================================================================= */

.sub-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.sub-tab {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.sub-tab:hover {
  color: var(--text);
}

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

/* ─── Attribute Bundles: Validation Bar ─── */

.ab-validation-bar {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.ab-validation-bar.valid {
  background: #ecfdf5;
  border: 1px solid #10b981;
}

.ab-validation-bar.invalid {
  background: #fef3c7;
  border: 1px solid #f59e0b;
}

.ab-validation-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.ab-validation-msg {
  font-weight: 500;
  color: var(--text);
}

.ab-validation-details {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.ab-progress {
  margin-bottom: 1rem;
}

.ab-progress-bar {
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}

.ab-progress-fill {
  height: 100%;
  transition: width 0.3s;
}

.ab-fill-bundles { background: #3b82f6; }
.ab-fill-unassigned { background: #f59e0b; }

.ab-progress-legend {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ab-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ab-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.ab-lc-bundles { background: #3b82f6; }
.ab-lc-unassigned { background: #f59e0b; }
.ab-lc-available { background: #e5e7eb; }

.ab-actions-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

/* ─── Attribute Bundles: Card Grid ─── */

.ab-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.ab-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ab-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.ab-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.ab-card-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.ab-card-title {
  flex: 1;
  min-width: 0;
}

.ab-card-title h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ab-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ab-card-actions {
  display: flex;
  gap: 4px;
}

.ab-card-actions .btn-icon {
  font-size: 0.9rem;
  padding: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.ab-card:hover .ab-card-actions .btn-icon { opacity: 1; }

.ab-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}

.ab-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  border: 1px solid #bfdbfe;
}

.ab-tag-x {
  background: none;
  border: none;
  cursor: pointer;
  color: #1e40af;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.5;
}

.ab-tag-x:hover {
  opacity: 1;
  color: var(--error);
}

.ab-empty-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.ab-card-footer {
  margin-top: 0.5rem;
}

.btn-xs {
  font-size: 11px;
  padding: 2px 8px;
}

/* ─── Attribute Bundles: Unassigned ─── */

.ab-unassigned-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.ab-unassigned-section h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.ab-unassigned-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ab-unassigned-attr {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ab-unassigned-attr:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ─── Attribute Bundles: Modal (Icon Picker, Attr Selection) ─── */

.ab-field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ab-icon-picker {
  position: relative;
}

.ab-icon-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 2rem;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s;
}

.ab-icon-preview:hover {
  border-color: var(--primary);
}

.ab-icon-grid {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  margin-top: 4px;
}

.ab-icon-grid[hidden] { display: none; }

.ab-icon-section {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 2px 2px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.ab-icon-section:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.ab-icon-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 1.25rem;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.15s;
}

.ab-icon-option:hover {
  background: var(--primary-light);
  transform: scale(1.1);
}

.ab-icon-option.selected {
  background: #dbeafe;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.ab-assignment-legend {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ab-selection-counter {
  margin-left: auto;
  font-weight: 600;
  color: var(--text);
}

.ab-attr-selection {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ab-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
}

.ab-checkbox-label:hover {
  background: var(--bg);
}

.ab-checkbox-label.ab-is-selected {
  background: #eff6ff;
  border-color: #93c5fd;
}

.ab-checkbox-label.ab-has-warning {
  background: #fffbeb;
  border-color: #fcd34d;
}

.ab-checkbox-name {
  flex: 1;
  font-size: 0.85rem;
}

.ab-assignment-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.ab-badge-other {
  background: #fef3c7;
  color: #92400e;
}

.ab-badge-current {
  background: #dbeafe;
  color: #1e40af;
}

/* ─── Scope Badges ─── */

.ab-scope-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
}

.ab-scope-org {
  background: #e0e7ff;
  color: #3730a3;
}

.ab-scope-gb {
  background: #dcfce7;
  color: #166534;
}

/* Scope badges inside tags */
.ab-tag .ab-scope-badge {
  margin-right: 2px;
}

/* Scope badges inside unassigned chips */
.ab-unassigned-attr .ab-scope-badge {
  margin-right: 2px;
}

/* ─── Quick-Assign Modal ─── */

.ab-assign-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ab-assign-option {
  text-align: left;
  justify-content: flex-start;
}

.ab-assign-option:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* =============================================================================
   SETTINGS PANEL
   ============================================================================= */

.settings-btn {
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.settings-section h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  min-width: 44px;
  height: 24px;
  margin-top: 2px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-text strong {
  font-size: 14px;
  color: var(--text);
}

.toggle-text .text-sm {
  font-size: 12px;
  line-height: 1.4;
}

/* =============================================================================
   ATTRIBUTE SELECTION BANNER (>64 threshold)
   ============================================================================= */

.attr-selection-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--info-bg);
  border: 1px solid var(--info);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.attr-selection-banner .banner-icon {
  font-size: 18px;
}

.attr-selection-banner .banner-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.attr-selection-banner .banner-text strong {
  color: var(--info);
}

.attr-selection-modal-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}

.attr-selection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}

.attr-selection-item:hover {
  background: var(--bg);
}

.attr-selection-counter {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.attr-selection-counter strong {
  color: var(--text);
}

/* =============================================================================
   PHASE 11: GESCHÄFTSPROZESSE
   ============================================================================= */

/* Process List */
.proc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

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

.proc-row-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.proc-row-content {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.proc-row-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.proc-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.proc-row-actions {
  display: flex;
  gap: 4px;
}

/* Process Steps (in modal) */
.proc-steps-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 40px;
}

.proc-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
}

.proc-step:hover {
  background: var(--surface);
  border-color: var(--text-muted);
}

.proc-step-deleted {
  opacity: 0.5;
  border-color: var(--error);
}

.proc-step-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}

.proc-step-handle:active {
  cursor: grabbing;
}

.proc-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.proc-step-info {
  flex: 1;
  min-width: 0;
}

.proc-step-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proc-step-preview {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proc-step-note {
  font-size: 11px;
  color: var(--info);
  margin-top: 2px;
}

.proc-step-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Drag & Drop States */
.proc-step-dragging {
  opacity: 0.4;
  border-style: dashed;
}

.proc-step-dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* New Elements Hint */
.proc-new-elements-hint {
  padding: 8px 14px;
  background: var(--info-bg);
  border: 1px solid var(--info);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text);
}

/* Element Picker */
.proc-elem-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50vh;
  overflow-y: auto;
}

.proc-pick-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.proc-pick-row:last-child {
  border-bottom: none;
}

.proc-pick-row:hover {
  background: var(--bg);
}

.proc-pick-row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.proc-pick-disabled {
  opacity: 0.5;
  cursor: default;
}

.proc-pick-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.proc-pick-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}

.proc-pick-line1 strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.proc-pick-meta {
  font-size: 11px;
  margin-left: auto;
  flex-shrink: 0;
}

.proc-pick-line2 {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.proc-pick-line2 .attr-badge {
  font-size: 10px;
  padding: 1px 5px;
}

/* Badge for deleted elements */
.badge-deleted {
  background: var(--error-bg);
  color: var(--error);
}

/* =============================================================================
   AI Process Suggestions (Phase 11.6)
   ============================================================================= */

.suggestions-panel {
  margin-bottom: 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.suggestions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
  border-bottom: 1px solid var(--border);
}

.suggestions-header h3 {
  margin: 0;
  font-size: 15px;
}

.suggestions-loading {
  padding: 32px 16px;
  text-align: center;
}

.suggestions-loading .spinner {
  margin: 0 auto 12px;
}

.suggestions-empty {
  padding: 24px 16px;
  text-align: center;
}

.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
}

.suggestion-card {
  padding: 14px 16px;
  background: var(--card);
}

.suggestion-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 12px;
}

.suggestion-card-header strong {
  font-size: 14px;
}

.suggestion-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.suggestion-steps-details {
  margin-bottom: 10px;
}

.suggestion-steps-details summary {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.suggestion-steps {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.suggestion-step {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.suggestion-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.suggestion-reasoning {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 0 0 8px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

.badge-scope {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  font-weight: 600;
}

.suggestion-actions {
  display: flex;
  gap: 6px;
}

/* =============================================================================
   Phase 12: Semantic Search
   ============================================================================= */

.badge-ding {
  background: #ede9fe;
  color: #5b21b6;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  display: inline-block;
  margin: 1px 2px;
}

.badge-tun {
  background: #e0f2fe;
  color: #075985;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  display: inline-block;
  margin: 1px 2px;
}

.badge-cell {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  display: inline-block;
  margin: 1px 2px;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-secondary {
  background: #f3f4f6;
  color: #374151;
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border, #e5e7eb);
  color: var(--text-muted, #6b7280);
}

.badge-topic {
  background: #fff7ed;
  color: #c2410c;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  display: inline-block;
  margin: 1px 2px;
}

.badge-action {
  background: #f0fdf4;
  color: #15803d;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  display: inline-block;
  margin: 1px 2px;
}

.badge-highlight {
  box-shadow: 0 0 0 2px var(--primary, #2563eb);
  font-weight: 600;
}

.badge-dim {
  opacity: 0.5;
}

/* Result Cards */
.ss-result-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.ss-result-clickable {
  cursor: pointer;
}
.ss-result-card:hover {
  border-color: var(--primary, #2563eb);
}
.ss-result-with-thumb {
  display: flex;
  gap: 12px;
}
.ss-result-icon.figure {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 6px;
  overflow: hidden;
}
.ss-result-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}
.ss-result-body {
  flex: 1;
  min-width: 0;
}
.ss-result-expanded {
  border-color: var(--primary, #2563eb);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
/* Search query textarea */
.ss-query-textarea {
  flex: 1;
  font-size: 15px;
  padding: 10px 14px;
  resize: none;
  overflow-y: auto;
  min-height: 42px;
  max-height: 130px;
  line-height: 1.4;
  font-family: inherit;
}

/* Learning Path Banner */
.ss-lp-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 8px 0;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
}
.ss-lp-matches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ss-lp-match {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 6px;
  background: #fff; border: 1px solid #bfdbfe;
  cursor: pointer; font-size: 12px; transition: all 0.15s;
}
.ss-lp-match:hover { background: #dbeafe; border-color: #3b82f6; }

/* Search Feedback */
.ss-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f3f4f6;
}
.ss-feedback-label { font-size: 12px; color: var(--text-muted); }
.ss-feedback-btn {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.2;
}
.ss-feedback-btn:hover { background: #f9fafb; border-color: #d1d5db; }
.ss-feedback-btn.active.ss-feedback-up { background: #f0fdf4; border-color: #86efac; }
.ss-feedback-btn.active.ss-feedback-down { background: #fef2f2; border-color: #fecaca; }
.ss-feedback-submitted .ss-feedback-label::after { content: ' — Danke!'; color: #22c55e; }

.ss-result-detail {
  background: var(--surface, #fff);
  border: 1px solid var(--primary, #2563eb);
  border-top: none;
  border-radius: 0 0 var(--radius, 8px) var(--radius, 8px);
  padding: 16px;
  margin-bottom: 8px;
}
.badge-tag {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.ss-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ss-result-rank {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted, #9ca3af);
  min-width: 24px;
}

.ss-result-title {
  font-size: 14px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-result-text {
  font-size: 13px;
  color: var(--text-secondary, #4b5563);
  margin-top: 6px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ss-result-attrs {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ss-attr-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.ss-attr-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #9ca3af);
}

.ss-doc-source {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ss-page {
  color: var(--text-muted, #9ca3af);
  font-weight: 600;
  white-space: nowrap;
}

.ss-context {
  font-size: 12px;
  color: var(--text-muted, #9ca3af);
  margin-top: 4px;
}

/* Score Bar */
.ss-score-bar {
  width: 60px;
  height: 6px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.ss-score-fill {
  height: 100%;
  background: var(--primary, #2563eb);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Vocabulary Tab */
.vocab-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.vocab-toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.vocab-term-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
@media (max-width: 900px) {
  .vocab-term-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .vocab-term-grid { grid-template-columns: 1fr; }
}
.vocab-term-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vocab-term-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  transition: background 0.15s;
}

.vocab-term-row:hover {
  background: var(--bg-secondary, #f8f9fa);
}

.vocab-term-row.selected {
  background: #eff6ff;
  border-color: var(--primary, #2563eb);
}

.vocab-checkbox {
  flex-shrink: 0;
}

.vocab-term-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.vocab-priority-btn {
  font-size: 16px;
  color: #d1d5db;
  cursor: pointer;
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0 2px;
  line-height: 1;
}
.vocab-priority-btn:hover { color: #f59e0b; }
.vocab-priority-btn.active { color: #f59e0b; }

.vocab-rename-btn {
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 6px;
}

.vocab-term-row:hover .vocab-rename-btn {
  opacity: 0.6;
}

.vocab-rename-btn:hover {
  opacity: 1 !important;
}
.vocab-suggestions-panel {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.vocab-suggestion-card {
  padding: 8px 0;
  border-bottom: 1px solid #fde68a;
}
.vocab-suggestion-card:last-child {
  border-bottom: none;
}

/* Similar terms panel (embedding-based) */
.vocab-similar-panel {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.vocab-similar-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #bfdbfe;
}
.vocab-similar-card:last-child { border-bottom: none; }
.vocab-similar-check { flex-shrink: 0; }
.vocab-similar-terms { flex: 1; font-size: 13px; }
.vocab-similar-arrow { margin: 0 6px; color: var(--text-muted); }
.vocab-similar-score {
  font-weight: 700;
  font-size: 13px;
  min-width: 42px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 8px;
}
.sim-high { background: #dcfce7; color: #166534; }
.sim-medium { background: #fef9c3; color: #854d0e; }
.sim-low { background: #fee2e2; color: #991b1b; }
.vocab-similar-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Glossary Panel */
.ss-glossary-panel {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius, 8px);
  padding: 10px 14px;
}

.ss-glossary-entry {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.4;
}

.ss-glossary-term {
  font-weight: 600;
  color: #065f46;
}

.ss-glossary-def {
  color: var(--text-secondary, #4b5563);
  margin-left: 6px;
}

.ss-glossary-def::before {
  content: "\2014 ";
  color: var(--text-muted, #9ca3af);
}

.ss-glossary-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-left: 3px solid #10b981;
  border-radius: var(--radius, 8px);
  padding: 10px 14px;
  margin-bottom: 6px;
}

.ss-glossary-card .ss-glossary-def {
  font-size: 13px;
  line-height: 1.5;
}

.ss-glossary-card .ss-glossary-def::before {
  content: none;
}

/* Sub-Tabs */
.ss-sub-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.ss-sub-tab:hover {
  color: var(--text-primary, #111827);
}

.ss-sub-tab.active {
  color: var(--primary, #2563eb);
  border-bottom-color: var(--primary, #2563eb);
}

/* Process tree */
.ss-process-tree {
  margin-bottom: 16px;
}

.ss-process-leader {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
  border-left: 3px solid #065f46;
}

.ss-process-child {
  background: var(--bg-secondary, #f8f9fa);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  padding: 8px 12px 8px 32px;
  margin-top: 2px;
  font-size: 13px;
  position: relative;
}

.ss-process-child::before {
  content: "\21B3";
  position: absolute;
  left: 12px;
  top: 8px;
  color: var(--text-muted, #9ca3af);
}

/* Process Badge */
.badge-process {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Document Cards */
.ss-doc-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.3s;
}

.ss-doc-card:hover {
  border-color: var(--primary, #2563eb);
}

.ss-doc-highlight {
  background: #eff6ff;
  border-color: var(--primary, #2563eb);
}

/* Clickable doc links */
.ss-doc-link {
  cursor: pointer;
  color: var(--primary, #2563eb);
  text-decoration: none;
  transition: color 0.15s;
}

.ss-doc-link:hover {
  text-decoration: underline;
}

/* Figure Cards */
.ss-figure-card {
  display: flex;
  gap: 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  padding: 12px;
  margin-bottom: 8px;
}

.ss-figure-img {
  flex-shrink: 0;
  width: 180px;
  max-height: 140px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-secondary, #f3f4f6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ss-figure-img img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}

.ss-figure-info {
  flex: 1;
  min-width: 0;
}

/* Synthesis Panel */
.ss-synthesis-card {
  background: var(--surface, #fff);
  border: 2px solid var(--primary, #2563eb);
  border-radius: var(--radius, 8px);
  padding: 20px;
}

.ss-synth-section {
  margin-bottom: 16px;
}

.ss-synth-section:last-child {
  margin-bottom: 0;
}

.ss-synth-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  margin: 0 0 8px;
  letter-spacing: 0.5px;
}

.ss-synth-section p {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.ss-synth-section ul,
.ss-synth-section ol {
  margin: 0;
  padding-left: 20px;
}

.ss-synth-section li {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.ss-steps-list li {
  padding: 4px 0;
}

.ss-warnings {
  background: #fef3c7;
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
}

.ss-warnings h4 {
  color: #92400e;
}

.ss-process-card {
  background: var(--bg-secondary, #f8f9fa);
  border-radius: var(--radius, 8px);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.ss-sources-list {
  list-style: none;
  padding-left: 0;
}

.ss-sources-list li::before {
  content: "\1F4C4 ";
}

/* =============================================================================
   Phase 15: Knowledge Map (Wissenslandkarte)
   ============================================================================= */

/* Summary bar */
.km-summary-bar {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.km-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.km-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.km-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Topic/Action tile grid */
.km-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.km-topic-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.km-topic-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.km-tile-large {
  grid-column: span 2;
  padding: 18px 20px;
}

.km-tile-large .km-tile-name {
  font-size: 17px;
}

.km-tile-medium {
  padding: 16px 18px;
}

.km-tile-medium .km-tile-name {
  font-size: 16px;
}

.km-tile-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.km-tile-stats {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.km-tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.km-tile-figure-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.km-warning-icon {
  color: #dc2626;
  font-size: 14px;
}

.km-action-tile {
  background: rgba(34, 197, 94, 0.04);
}

.km-show-more-wrapper {
  grid-column: 1 / -1;
  text-align: center;
  padding: 8px 0;
}

/* View toggle button group */
.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border);
}

.btn-group .btn:last-child {
  border-right: none;
}

.btn-group .btn.active {
  background: var(--primary);
  color: white;
}

/* Detail tabs */
.km-detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  margin-top: 12px;
}

.km-detail-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.15s;
}

.km-detail-tab:hover {
  color: var(--text);
}

.km-detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Topic header */
.km-topic-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.km-topic-meta {
  display: flex;
  gap: 8px;
}

/* Action groups */
.km-action-group {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.km-action-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
}

.km-action-group-header:hover {
  background: #f1f5f9;
}

.km-collapse-icon {
  font-size: 10px;
  color: var(--text-muted);
  width: 14px;
}

.km-group-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.km-action-group-body {
  border-top: 1px solid var(--border);
}

/* Warning card */
.km-warning-card {
  border-left: 3px solid #dc2626 !important;
}

/* Document card */
.km-doc-card {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.km-doc-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.km-doc-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.km-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Figure grid */
.km-figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.km-figure-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.km-figure-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #f1f5f9;
}

.km-figure-info {
  padding: 8px 12px;
}

.km-figure-title {
  font-size: 13px;
  font-weight: 500;
}

.km-figure-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Related badges */
.km-related-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.km-clickable-badge {
  cursor: pointer;
}

.km-clickable-badge:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Process card */
.km-process-card {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.km-process-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Glossary entry */
.km-glossary-entry {
  padding: 8px 14px;
  border-left: 3px solid var(--primary);
  margin-bottom: 8px;
  background: #f8fafc;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
}

/* Cell detail */
.km-cell-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Matrix enhancements for knowledge map */
.matrix-scroll-container {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.matrix-scroll-container .matrix-table {
  width: 100%;
}

.matrix-corner {
  min-width: 120px;
}

.matrix-scroll-container thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.matrix-scroll-container .matrix-row-header {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

.matrix-scroll-container .matrix-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  background: var(--surface);
}

.matrix-col-header {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 8px 4px;
  font-size: 12px;
  max-width: 40px;
  white-space: nowrap;
}

.matrix-row-header {
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.matrix-cell {
  text-align: center;
  font-size: 12px;
  min-width: 36px;
  padding: 4px;
}

.matrix-cell-filled {
  font-weight: 600;
}

.matrix-cell-empty {
  background: #fafafa;
}

/* Element card meta line */
.element-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =============================================================================
   Phase 19: Prozessketten
   ============================================================================= */

/* Document groups */
.chain-doc-group { margin-bottom: 20px; }
.chain-doc-header {
  font-weight: 600;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* Leader cards in list */
.chain-leader-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.chain-leader-card:hover { background: #f8fafc; }

.chain-leader-name { font-weight: 600; font-size: 14px; }
.chain-leader-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chain-leader-badges { display: flex; gap: 6px; align-items: center; }

/* Status badges */
.chain-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.chain-status-suggested { background: #fef3c7; color: #92400e; }
.chain-status-confirmed { background: #dcfce7; color: #166534; }
.chain-status-rejected { background: #fee2e2; color: #991b1b; }

/* Type badges */
.chain-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.chain-type-linear { background: #eff6ff; color: #1d4ed8; }
.chain-type-checklist { background: #f0fdf4; color: #15803d; }

/* Detail view */
.chain-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.chain-detail-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.chain-name-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
}
.chain-type-select { width: auto; }
.chain-detail-actions { display: flex; gap: 8px; align-items: center; }

/* Leader element */
.chain-leader-element {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 4px;
}

/* Step visualization */
.chain-steps { padding-left: 6px; }

.chain-connector {
  width: 2px;
  height: 16px;
  background: var(--primary);
  margin-left: 18px;
}

.chain-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.chain-step-marker {
  min-width: 38px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.chain-step-card {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.chain-step-title { font-weight: 600; font-size: 13px; }
.chain-step-preview { font-size: 12px; color: var(--text-muted); margin-top: 4px; max-height: 60px; overflow: hidden; }
.chain-step-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.chain-branch-condition {
  padding: 3px 8px;
  background: #fef3c7;
  border-radius: 4px;
  font-size: 11px;
  color: #92400e;
  margin-bottom: 4px;
}

.chain-step-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.chain-step:hover .chain-step-drag-handle { opacity: 1; }

.chain-step-dragging { opacity: 0.4; }
.chain-step-dragover .chain-step-card { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }

.chain-unlink-btn {
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 16px;
  color: #dc2626;
  flex-shrink: 0;
}
.chain-step:hover .chain-unlink-btn { opacity: 1; }

/* Linked/unlinked indicators in list */
.chain-linked-icon { color: #1e40af; font-size: 13px; }
.chain-unlinked-icon { color: #f59e0b; font-size: 13px; }

/* Add step picker */
.chain-picker-item {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.chain-picker-item:hover { background: #f0fdf4; border-color: #16a34a; }
.chain-picker-title { font-weight: 600; font-size: 13px; }
.chain-picker-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.chain-picker-preview { font-size: 12px; color: var(--text-muted); margin-top: 4px; max-height: 40px; overflow: hidden; }

/* Chain name badge on element cards */
.chain-name-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  cursor: pointer;
}
.chain-name-badge:hover { background: #dbeafe; }

/* =============================================================================
   GAP ANALYSIS (Lückenanalyse)
   ============================================================================= */

/* Summary bar */
.ga-summary-bar { margin-bottom: 16px; }
.ga-summary-row { display: flex; gap: 24px; flex-wrap: wrap; }
.ga-stat { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.ga-stat-value { font-size: 1.6em; font-weight: 700; line-height: 1.2; }
.ga-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ga-stat-red { color: #ef4444; }
.ga-stat-green { color: #22c55e; }
.ga-warning { color: #b45309; background: #fef3c7; padding: 6px 12px; border-radius: 6px; font-size: 13px; margin-top: 8px; }
.ga-hint { color: var(--text-muted); font-size: 13px; margin-top: 8px; }

/* Traffic light dots */
.ga-status-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ga-status-green { background: #22c55e; }
.ga-status-yellow { background: #eab308; }
.ga-status-red { background: #ef4444; }

/* Coverage bars */
.ga-coverage-bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.ga-coverage-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.ga-fill-green { background: #22c55e; }
.ga-fill-yellow { background: #eab308; }
.ga-fill-red { background: #ef4444; }
.ga-coverage-pct { font-size: 12px; color: var(--text-muted); }

/* Document card grid */
.ga-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ga-doc-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.ga-doc-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-color: var(--accent); }
.ga-doc-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ga-doc-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Gap pills */
.ga-gap-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ga-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.ga-pill-high { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.ga-pill-medium { background: #fefce8; color: #a16207; border: 1px solid #fde68a; }
.ga-pill-low { background: #f0f9ff; color: #1e40af; border: 1px solid #bfdbfe; }
.ga-pill-more { background: #f3f4f6; color: var(--text-muted); border: 1px solid #e5e7eb; }
.ga-pill-unique { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.ga-pill-red { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.ga-pill-green { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Document detail header */
.ga-doc-detail-header { display: flex; align-items: center; margin-bottom: 8px; }

/* Compare: Venn diagram */
.ga-venn-container { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 8px; }
.ga-venn-col { min-height: 60px; }
.ga-venn-col h4 { font-size: 13px; margin-bottom: 6px; color: var(--text-muted); }
.ga-venn-shared { background: #f0fdf4; border-radius: 8px; padding: 10px; }
.ga-venn-only { padding: 10px; }

/* Compare: Semantic type bars */
.ga-semtype-compare { margin-top: 8px; }
.ga-semtype-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ga-semtype-label { width: 100px; font-size: 12px; text-align: right; flex-shrink: 0; }
.ga-semtype-bars { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ga-semtype-bar { height: 18px; border-radius: 4px; font-size: 11px; padding: 0 6px; line-height: 18px; color: #fff; min-width: 24px; }
.ga-bar-a { background: #3b82f6; }
.ga-bar-b { background: #8b5cf6; }

/* Overlap score */
.ga-overlap-score { text-align: center; }

/* =============================================================================
   KNOWLEDGE PATHS (Wissenspfade)
   ============================================================================= */

.kp-path-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.kp-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.kp-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-color: var(--accent); }
.kp-card-header { display: flex; gap: 6px; margin-bottom: 6px; }
.kp-card-title { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.kp-card-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 6px; }
.kp-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }

/* Generator */
.kp-gen-section { margin-bottom: 16px; }
.kp-gen-section h3 { font-size: 14px; margin-bottom: 8px; }
.kp-gen-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kp-gen-fields label { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }

/* Steps */
.kp-steps-list { display: flex; flex-direction: column; gap: 8px; }
.kp-step-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
}
.kp-step-num {
  width: 28px; height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.kp-step-body { flex: 1; min-width: 0; }
.kp-step-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.kp-step-reason { font-size: 12px; color: var(--text-muted); margin: 2px 0; }
.kp-step-preview { font-size: 12px; color: var(--text-muted); margin: 4px 0 2px; max-height: 40px; overflow: hidden; }
.kp-step-tags { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }

/* Warnings */
.kp-warnings { margin: 8px 0; }
.kp-warning-item { background: #fef3c7; color: #92400e; padding: 6px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 4px; }

/* Meta sections */
.kp-meta-section { font-size: 13px; color: var(--text-muted); margin: 6px 0; padding: 8px; background: #f9fafb; border-radius: 6px; }
.kp-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.kp-detail-header h3 { margin: 0; }

/* Generator preview */
.kp-gen-preview { background: #f9fafb; padding: 16px; border-radius: 8px; }
.kp-gen-preview-header h3 { margin: 0 0 4px; }
.kp-gen-preview-header p { margin: 0 0 8px; color: var(--text-muted); font-size: 13px; }

/* Step editor: drag handle + dragging states */
.kp-step-handle { cursor: grab; font-size: 18px; color: #d1d5db; user-select: none; flex-shrink: 0; line-height: 1; }
.kp-step-handle:hover { color: var(--text-primary); }
.kp-step-draggable { transition: opacity 0.15s, border-color 0.15s; }
.kp-step-dragging { opacity: 0.4; }
.kp-step-dragover { border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.kp-step-card .kp-remove-step { opacity: 0; transition: opacity 0.15s; font-size: 14px; color: #ef4444; flex-shrink: 0; }
.kp-step-card:hover .kp-remove-step { opacity: 0.6; }
.kp-step-card .kp-remove-step:hover { opacity: 1 !important; }
.kp-cat-select { font-size: 11px; padding: 1px 4px; border-radius: 4px; border: 1px solid #e5e7eb; background: #f9fafb; }

/* Element picker */
.kp-picker-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px; border: 1px solid var(--border-light);
  border-radius: 6px; margin-bottom: 4px; cursor: pointer; transition: background 0.1s;
}
.kp-picker-item:hover { background: #f0fdf4; border-color: #86efac; }
.kp-picker-selected { background: #eff6ff; border-color: #93c5fd; }
.kp-picker-existing { opacity: 0.5; cursor: default; }
.kp-picker-info { flex: 1; min-width: 0; }
