/* Import Wix Madefor Fonts */
@import url('https://fonts.googleapis.com/css2?family=Wix+Madefor+Display:wght@400..800&family=Wix+Madefor+Text:ital,wght@0,400..800;1,400..800&display=swap');

/* ===== MATRIX LAYER GUARDRAIL ===== */
@layer legacy, matrix;            /* legacy < matrix (matrix wins) */

:root {
  /* authoritative tokens - match console measurements */
  --plugin-col: 340px;  /* matches pw in console */
  --active-col: 80px;
  --updates-col: 80px;  /* 340 + 80 = 420 shown in console */
  --site-col: 220px;
  --z-head: 300;        /* site headers */
  --z-plugin: 303;      /* plugin */
  --z-active: 302;      /* active */
  --z-updates: 301;     /* updates */
  --z-cell: 100;        /* body */
}

/* ===== NEW CANONICAL RULES (WIN) ===== */
@layer matrix {
  /* keep one scrollport only */
  .table-wrapper[data-matrix-scroller] {
    overflow: auto !important;
    max-height: 70vh;
    position: relative;
  }
  .matrix-wrap, .matrix-scroll { overflow: visible !important; } /* neutralized */

  /* Always lift legacy modal + any dialog above the Matrix */
.modal,
.modal-dialog,
[role="dialog"] {
  position: fixed !important;
  z-index: 2147483647 !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}

/* Common backdrops */
.modal-backdrop,
.overlay,
.overlay-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483646 !important;
  background: rgba(0,0,0,0.35) !important;
  display: none !important;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.show,
.overlay.show,
.overlay-backdrop.show {
  display: flex !important;
}

/* authoritative sticky header rules */
  #matrix-table.matrix-v2 thead th {
    position: sticky !important;
    top: 0 !important;
    background: #fff !important;
    z-index: 50 !important;
  }
  #matrix-table.matrix-v2 thead th.col-plugin  {
    left: 0 !important;
    z-index: 303 !important;
    min-width: var(--plugin-col); max-width: var(--plugin-col); width: var(--plugin-col);
  }
  #matrix-table.matrix-v2 thead th.col-active  {
    left: var(--plugin-col) !important;
    z-index: 302 !important;
    min-width: var(--active-col); max-width: var(--active-col); width: var(--active-col); text-align: center;
  }
  #matrix-table.matrix-v2 thead th.col-updates {
    left: calc(var(--plugin-col) + var(--active-col)) !important;
    z-index: 301 !important;
    min-width: var(--updates-col); max-width: var(--updates-col); width: var(--updates-col); text-align: center;
  }
  #matrix-table.matrix-v2 thead th.site-header.site-header-clickable {
    background: var(--site-header-bg, #f0f9ff) !important;
  }
  #matrix-table.matrix-v2 thead th.site-header { z-index: 250 !important; }

  /* body sticky trio */
  #matrix-table.matrix-v2 tbody td.plugin-cell  {
    position: sticky !important;
    left: 0 !important;
    z-index: 190 !important;
    background: #fff !important;
  }
  #matrix-table.matrix-v2 tbody td.active-cell  {
    position: sticky !important;
    left: var(--plugin-col) !important;
    z-index: 189 !important;
    background: #fff !important;
  }
  #matrix-table.matrix-v2 tbody td.updates-cell {
    position: sticky !important;
    left: calc(var(--plugin-col) + var(--active-col)) !important;
    z-index: 188 !important;
    background: #fff !important;
  }

  /* ordinary cells always below stickies */
  #matrix-table.matrix-v2 tbody td { position: relative; z-index: var(--z-cell); }
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Wix Madefor Text', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #e8eaec !important;
  color: #374151;
  min-height: 100vh;
}

/* Header Styles */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  gap: 24px;
  padding: 20px 20px 8px 20px;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header h1 .dashboard-title,
.header h1 .matrix-title {
  font-family: 'Wix Madefor Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  color: #469168;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: -5px;
  margin-left: 15px !important;
}

.header-stats {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

#app-main .header-stats {
  justify-content: flex-start;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.account-menu {
  position: relative;
}

.account-menu-toggle {
  background: #f3f4f6;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #1f2937;
  font: 600 14px 'Wix Madefor Display', system-ui, -apple-system, 'Wix Madefor Text', sans-serif;
  white-space: nowrap;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.account-menu-toggle:hover {
  background: #dfe3e9;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.12);
}

.account-menu-toggle:focus-visible {
  outline: 2px solid #469168;
  outline-offset: 2px;
}

.account-menu-toggle-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#account-bar.matrix-view .account-menu-toggle {
  background: #e5e7eb;
}

.account-menu-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.account-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  min-width: 190px;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  z-index: 1200;
}

.account-menu-dropdown[hidden] {
  display: none;
}

.account-menu-item {
  padding: 8px 16px;
  text-decoration: none;
  color: #111827;
  font: 500 14px 'Wix Madefor Text', system-ui, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.account-menu-item:hover {
  background: #f3f4f6;
}

.header-buttons {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  align-items: center;
}

/* Stats Cards */
.mini-stat {
  text-align: center;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  min-width: 70px;
}

.mini-stat.clickable-tile { cursor: default; transition: none; border-color: #e5e7eb !important; }
.mini-stat.clickable-tile:hover { background: inherit !important; border-color: #e5e7eb !important; transform: none !important; box-shadow: none !important; outline: none !important; }
.mini-stat.clickable-tile.active { cursor: default; background: #10b981; border-color: #10b981; color: white; }
.mini-stat.clickable-tile.active .mini-stat-number,
.mini-stat.clickable-tile.active .mini-stat-label { color: white; }

.mini-stat-number {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: #111827;
  line-height: 1.2;
}

.mini-stat-label {
  font-size: 10px;
  color: #6b7280;
  text-transform: uppercase;
  font-weight: 500;
  margin: 2px 0 0;
  line-height: 1;
}

/* Button Styles */
.btn {
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  font-family: 'Wix Madefor Text', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid;
  transition: all 0.2s ease;
  height: 45px;
  min-width: 120px;
  cursor: pointer;
}

.btn-primary {
  background: #469168;
  color: white;
  border-color: #469168;
}

.btn-secondary {
  background: white;
  color: #6b7280;
  border-color: #d1d5db;
}

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

.btn-primary:hover {
  background: #3d7957;
  border-color: #3d7957;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #9ca3af;
  color: #374151;
}

.btn-cancel {
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-save {
  padding: 8px 16px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

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

#triggerAllBtn[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

/* Default nav button styling */
.top-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #1f2937;
  font: 600 14px 'Wix Madefor Text', 'Inter', sans-serif;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.top-nav-btn img {
  width: 16px;
  height: 16px;
}

.top-nav-btn:hover {
  background: #e5e7eb;
}

body[data-page="dashboard"] .top-nav-btn[data-nav="dashboard"] {
  background: #469168;
  border-color: #469168;
  color: #ffffff;
}

body[data-page="matrix"] .top-nav-btn[data-nav="matrix"] {
  background: #469168;
  border-color: #469168;
  color: #ffffff;
}

/* Main Content */
.main-content {
  padding: 8px 20px 20px 20px;
  background-color: transparent;
}

body[data-dashboard-view="plugins-to-sites"] .main-content,
body[data-dashboard-view="sites-to-plugins"] .main-content {
  background-color: transparent;
}

/* Dashboard-only card widths: align filters, tables, pagination, and notes */
#app-main[data-view="dashboard"] .filters,
#app-main[data-view="dashboard"] .data-table,
#app-main[data-view="dashboard"] .pagination,
#app-main[data-view="dashboard"] #site-notes-wrap,
#app-main[data-view="dashboard"] #plugin-notes-wrap {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

body[data-dashboard-view="plugins-to-sites"] #plugin-notes-wrap {
  display: none !important;
}

/* View Toggle */
.view-toggle {
  display: flex;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  margin-right: 24px;
  flex-shrink: 0;
}

.toggle-btn {
  padding: 12px 24px;
  background: white;
  border: none;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Wix Madefor Text', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
  text-decoration: none;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: #469168 !important;
  color: white !important;
}

.toggle-btn:hover:not(.active) {
  background: #f9fafb;
  color: #374151;
}

/* Filters */
.filters {
  background: rgba(255, 255, 255, 0);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.filter-inputs {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.filter-input, .filter-select, .search-input, .select-input {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Wix Madefor Text', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: white;
  min-width: 0;
}

.filter-input {
  width: 180px;
  min-width: 120px;
}

.search-input {
  width: 200px;
}

.filter-select {
  width: 140px;
  min-width: 120px;
}

@media (max-width: 768px) {
  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-inputs {
    justify-content: stretch;
  }

  .filter-input {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .filter-select {
    flex: 1;
    min-width: 120px;
  }
}

.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #6b7280;
  padding: 6px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

/* Baseline Mode */
.baseline-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.baseline-toggle.active {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d40af;
}

.baseline-cell {
  opacity: 0.4;
  background: #f9fafb;
}

.baseline-diff {
  background: #fef3c7;
  border: 2px solid #f59e0b;
}

/* Progress UI */
.progress-box {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: none;
}

.progress-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-bar-wrap {
  height: 10px;
  background: #f3f4f6;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 10px;
  width: 0%;
  background: #10b981;
  transition: width .3s ease;
}

.small {
  font-size: 12px;
  color: #6b7280;
}

.results-list {
  margin-top: 8px;
  max-height: 160px;
  overflow: auto;
  font-size: 12px;
  color: #374151;
}

.result-ok {
  color: #166534;
}

.result-fail {
  color: #b91c1c;
}

/* ================================
   DASHBOARD DATA TABLE (ORIGINAL)
   ================================ */

.data-table {
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  width: 100%;
  margin: 0 auto 24px;
}

/* Allow sticky behavior on the dashboard tables */
.data-table-main {
  position: relative;
}

/* Table core */
.data-table table {
  width: 100%;
  border-collapse: collapse;
}

/* Table header */
.data-table th {
  background: #f9fafb;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table-main[data-ready] thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #f9fafb;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

/* First column (site/plugin name) */
.data-table th:first-child,
.data-table td:first-child {
  max-width: 220px;
  min-width: 180px;
  width: 220px;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.4;
}

/* Table body cells */
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
  vertical-align: middle;
}

/* Row hover */
.data-table tbody tr:hover {
  background: #f9fafb;
}

/* Ensure plugin column (first column) maintains fixed width for stability */
.matrix-table th.plugin-header:first-child,
.matrix-table td.plugin-cell:first-child {
  width: var(--plugin-width) !important;
  min-width: var(--plugin-width) !important;
  max-width: var(--plugin-width) !important;
}

/* Count Badges */
.count-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  min-width: 24px;
  text-align: center;
  cursor: pointer;
  position: relative;
}

.count-badge:hover {
  opacity: 0.8;
}

.count-active {
  background: #dcfce7;
  color: #166534;
}

.count-inactive {
  background: #f3f4f6;
  color: #374151;
}

.count-updates {
  background: #fef3c7;
  color: #92400e;
}

.count-total {
  background: #dbeafe;
  color: #1e40af;
}

/* Badge Styles */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

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

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

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

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

/* Tooltips */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-content {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  background-color: #1f2937;
  color: white;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: normal;
  min-width: 200px;
  max-width: 300px;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}

.tooltip .tooltip-content.above::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-width: 5px;
  border-style: solid;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-color: #1f2937 transparent transparent transparent;
}

.tooltip .tooltip-content.below::after {
  bottom: 100%;
  left: 50%;
  margin-left: -5px;
  border-color: transparent transparent #1f2937 transparent;
}

.tooltip:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
}

.tooltip-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tooltip-list li {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-list li:last-child {
  border-bottom: none;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.pagination-info {
  font-size: 14px;
  color: #6b7280;
}

.pagination-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.page-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;
}

.page-select select {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}

.page-btn:hover {
  background: #f9fafb;
}

.page-btn.active {
  background: #469168;
  color: white;
  border-color: #469168;
}

.page-btn.disabled {
  color: #9ca3af;
  cursor: not-allowed;
  pointer-events: none;
}

/* Row Status */
.row-status {
  margin-left: 6px;
  font-size: 12px;
  vertical-align: middle;
}

.row-status.ok {
  color: #166534;
}

.row-status.fail {
  color: #b91c1c;
}

/* Trigger Options */
.trigger-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.trigger-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: white;
  min-width: 200px;
  box-shadow: 0px 8px 16px rgba(0,0,0,0.1);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  z-index: 1000;
  right: 0;
  top: 100%;
  margin-top: 4px;
}

.dropdown-content.show {
  display: block;
}

.dropdown-item {
  color: #374151;
  padding: 10px 16px;
  text-decoration: none;
  display: block;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.dropdown-item:hover {
  background-color: #f9fafb;
}

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

/* No Data State */
.no-data {
  text-align: center;
  padding: 48px;
  color: #64748b;
  background-color: #ffffff;
  border-radius: 25px;
}

  /* Ensure primary button styles are available immediately to avoid FOUC on dynamic pages */
  .btn { padding: 12px 16px; border-radius: 8px; text-decoration: none; font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid; transition: all 0.2s ease; height: 45px; min-width: 120px; }
  .btn-primary { background: #469168; color: white; border-color: #469168; }
  .btn-secondary { background: white; color: #6b7280; border-color: #d1d5db; }
  .btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
  .btn-primary:hover { background: #3d7957; border-color: #3d7957; }
  .btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; color: #374151; }

/* Matrix Specific Styles */
:root {
  --plugin-width: 220px;
  --active-width: 80px;
  --updates-width: 80px;

  --plugin-border-width: 2px;
  --active-border-width: 1px;
  --updates-border-width: 2px;

  /* Fixed pixel offsets for sticky positioning */
  --active-left: 220px;
  --updates-left: 300px;

  /* Total sticky width for the gutter */
  --sticky-total: 380px;

  --site-width: 165px; /* wider site columns for better readability */
}

/* Single-table Matrix Styles */
.matrix-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}

.matrix-toolbar .spacer {
  flex: 1;
}

.matrix-table-wrap {
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Modal interaction styles */
td.plugin-cell {
  cursor: pointer;
}

th.site-header {
  cursor: pointer;
}

td.plugin-cell:hover,
th.site-header:hover {
  background: #f8fafc;
}

.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f5f7fa;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px;
  font-weight: 600;
  color: #374151;
}

.matrix-table tbody td {
  border-bottom: 1px solid #f1f3f5;
  padding: 10px 12px;
}

.c-plugin  { width: 320px; }
.c-active  { width: 90px;  }
.c-updates { width: 110px; }
.c-site    { width: 220px; }

.sticky.col-plugin  {
  left: 0;
  background: #fff;
  z-index: 2;
  position: sticky;
}

.sticky.col-active  {
  left: 320px;
  background: #fff;
  z-index: 2;
  position: sticky;
}

.sticky.col-updates {
  left: 430px;
  background: #fff;
  z-index: 2;
  position: sticky;
}

.site-header {
  text-align: center;
  background: var(--site-header-bg, #f5f7fa);
}

.site-header-clickable {
  cursor: pointer;
  background: var(--site-header-bg, #f0f9ff) !important;
  transition: background-color 0.2s;
  border: none;
}

.site-header-clickable:hover {
  background: #ffffff !important;
}

.site-title  {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-sub    {
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status Dots */
.status-indicator {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #d7dadd;
  background: transparent;
}

.status-active    {
  background: #22c55e;
  border-color: #22c55e;
}

.status-update    {
  position: relative;
}

.status-update::after {
  content: "!";
  position: absolute;
  right: -8px;
  top: -8px;
  font-weight: 700;
  font-size: 10px;
  color: #f59e0b;
}

.status-inactive  {
  background: transparent;
  border-color: #c7cbd1;
}

.status-none      {
  opacity: 0.3;
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  color: #0ea5e9;
  cursor: pointer;
  font: inherit;
}

.linklike:hover {
  text-decoration: underline;
}

.matrix-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.empty {
  text-align: center;
  color: #6b7280;
  padding: 24px;
}

.matrix-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: #6b7280;
}

.density-controls {
  display: flex;
  gap: 8px;
}

.density-btn {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.density-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.matrix-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  position: relative;
}

.table-wrapper {
  overflow: auto;
  max-height: 70vh;
  position: relative;
  /* Ensure horizontal scrolling works properly */
  overflow-x: auto;
  overflow-y: auto;
}

/* Make only ONE scroll container */
.matrix-wrap {
  overflow: auto !important;
  max-height: 70vh;
  position: relative;
}

/* Neutralize the inner scroller so sticky top works */
.matrix-scroll {
  overflow: visible !important;
}

/* ONE scroll container: the wrapper around the table */
.table-wrapper {
  overflow: auto !important;      /* both X and Y scroll here */
  max-height: 70vh !important;    /* vertical scroll cutoff */
  position: relative !important;
}

/* All other wrappers must NOT scroll */
.matrix-wrap,
.matrix-scroll {
  overflow: visible !important;
}

/* Chrome quirk: sticky in tables needs separate collapse */
#matrix-table.matrix-v2 { border-collapse: separate !important; }

/* All headers stick to the top of the scrollport */
#matrix-table.matrix-v2 thead th {
  position: sticky !important;
  top: 0 !important;
  background: #fff !important;
  z-index: 250 !important;      /* higher than body cells */
}

/* First-three headers also stick horizontally */
#matrix-table.matrix-v2 thead th.col-plugin  { left: 0 !important;                                          z-index: 303 !important; }
#matrix-table.matrix-v2 thead th.col-active  { left: var(--plugin-col, 260px) !important;                   z-index: 302 !important; }
#matrix-table.matrix-v2 thead th.col-updates { left: calc(var(--plugin-col,260px) + var(--active-col,80px)) !important; z-index: 301 !important; }

/* AUTHORITATIVE MATRIX STICKY RULES - These override everything else */
#matrix-table.matrix-v2 {
  width: max-content !important;  /* not 100% */
  min-width: max-content !important;
  border-collapse: separate !important;
  border-spacing: 0;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  table-layout: fixed;
}

/* ALL headers sticky to top */
#matrix-table.matrix-v2 thead th {
  position: sticky !important;
  top: 0 !important;
  background: #fff !important;
  z-index: 50 !important;
  padding: 12px 8px;
  border-right: 1px solid #f3f4f6;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* First 3 header cells: also sticky to the LEFT with higher z-index */
#matrix-table.matrix-v2 thead th.plugin-header,
#matrix-table.matrix-v2 thead th.col-plugin {
  position: sticky !important;
  left: 0 !important;
  z-index: 103 !important;
  background: #fff !important;
}

#matrix-table.matrix-v2 thead th.active-header,
#matrix-table.matrix-v2 thead th.col-active {
  position: sticky !important;
  left: var(--plugin-col, 260px) !important;
  z-index: 102 !important;
  background: #fff !important;
  padding-left: 5px !important;
  padding-right: 5px !important;
}

#matrix-table.matrix-v2 thead th.updates-header,
#matrix-table.matrix-v2 thead th.col-updates {
  position: sticky !important;
  left: calc(var(--plugin-col, 260px) + var(--active-col, 80px)) !important;
  z-index: 101 !important;
  background: #fff !important;
  padding-left: 5px !important;
  padding-right: 5px !important;
}

/* Body cells */
#matrix-table.matrix-v2 tbody td {
  border-right: 1px solid #f3f4f6;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  padding: 10px 8px;
  font-size: 14px;
  border-bottom: 1px solid #f1f3f5;
}

/* Site Headers - lower z-index so they slide under frozen columns */
#matrix-table.matrix-v2 .site-header {
  min-width: var(--site-width);
  max-width: var(--site-width);
  width: var(--site-width);
  font-size: 12px;
  line-height: 1.2;
  z-index: 50 !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-table tbody tr:hover td {
  background: #fbfbfc;
}

.matrix-table tbody tr:hover .plugin-cell,
.matrix-table tbody tr:hover .active-cell,
.matrix-table tbody tr:hover .updates-cell {
  background: #fbfbfc;
}

/* Network Styles */
.network-expand-btn {
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  color: #6b7280;
  padding: 1px;
  border-radius: 2px;
  transition: all 0.2s ease;
  display: inline-block;
  z-index: 25;
  position: absolute;
  bottom: 0px;
  right: 0px;
  background: rgba(255,255,255,0.9);
}

.network-expand-btn:hover {
  background: rgba(107, 114, 128, 0.2);
  color: #374151;
  transform: scale(1.1);
}

.network-expand-btn.expanded {
  color: #374151;
  background: rgba(59, 130, 246, 0.1);
}

.matrix-table th[style*="display: none"],
.matrix-table td[style*="display: none"] {
  display: none !important;
  width: 0 !important;
  padding: 0 !important;
  border: none !important;
}

.scroll-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}

.matrix-container:hover .scroll-hint {
  opacity: 1;
}

/* Modal Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-backdrop.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  font-family: 'Wix Madefor Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #374151;
  margin: 0;
  line-height: 1.4;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
  font-size: 14px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Wix Madefor Text', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Tags */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-option {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  user-select: none;
}

.tag-option:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.tag-option:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.tag-option.selected {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0f172a;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.35);
}

.tag-option.selected:hover {
  background: #bae6fd;
}

.metadata-indicators {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.metadata-tag {
  font-size: 8px;
  padding: 1px 4px;
  border-radius: 8px;
  background: #e5e7eb;
  color: #374151;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

/* Loading Spinner */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  border-top-color: #3b82f6;
  animation: spin 1s ease-in-out infinite;
}

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

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  text-align: center;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #6b7280;
}

.stat-blue { color: #3b82f6; }
.stat-red { color: #dc2626; }
.stat-green { color: #059669; }
.stat-gray { color: #6b7280; }

/* Links */
.plugin-link,
.site-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}

.plugin-link:hover,
.site-link:hover {
  text-decoration: underline;
}

/* Modal portal + overlay (z-index above sticky headers & pagination) */
#pv-modal-host {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none; /* host doesn't block page, overlay will */
}

/* Enhanced site header clickability */
.site-header-clickable {
  cursor: pointer;
  transition: background-color 0.2s;
  background-color: var(--site-header-bg, #f0f9ff) !important;
  border: none;
}

.site-header-clickable:hover {
  background-color: #ffffff !important;
}

/* MatrixToolbar and Pager Styles */
.matrix-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 4px 12px;
  flex-wrap: wrap;
}

.matrix-toolbar input {
  width: 220px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.matrix-toolbar select {
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.matrix-toolbar .chk {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #3b4450;
  font-size: 14px;
}

.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 4px 6px;
  color: #3b4450;
}

.pager .btn {
  padding: 6px 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

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

.pager select {
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
