/* ============================================= */
/* CMT GLOBAL STYLES (Modals & Panels)          */
/* Must be global - appended to document.body   */
/* ============================================= */

.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: 1000;
}

.modal-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #1e293b;
    flex: 1;
}

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

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ============================================= */
/* CMT SCOPED STYLES - Main Interface           */
/* Scoped to .cmt-container to avoid conflicts */
/* ============================================= */

.cmt-container {
  /* Container itself gets the page styling */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: transparent; /* Use main site background */
  padding: 20px;
  color: #2c3e50;

  * {
      box-sizing: border-box;
  }

  .header {
      background: white;
      padding: 20px;
      border-radius: 8px;
      margin-bottom: 20px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  
  .header h1 {
      font-size: 24px;
      margin-bottom: 8px;
  }
  
  .header p {
      color: #64748b;
      font-size: 14px;
  }
  
  .controls {
      background: white;
      padding: 16px 20px;
      border-radius: 8px;
      margin-bottom: 20px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      display: flex;
      gap: 12px;
      align-items: center;
  }
  
  .btn {
      padding: 8px 16px;
      border: 1px solid #3b82f6;
      background: #3b82f6;
      color: white;
      border-radius: 6px;
      font-size: 14px;
      cursor: pointer;
      transition: all 0.2s;
  }
  
  .btn:hover {
      background: #2563eb;
  }
  
  .btn-secondary {
      background: white;
      color: #3b82f6;
  }
  
  .btn-secondary:hover {
      background: #f8fafc;
  }
  
  /* Main Grid Container */
  .config-grid-wrapper {
      background: white;
      border-radius: 8px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      /* No overflow here - let sticky headers work with viewport */
  }
  
  .config-grid-wrapper.col-program-collapsed {
      --col1-width: 36px;
  }
  
  .config-grid-wrapper.col-program_course-collapsed {
      --col2-width: 36px;
  }
  
  .config-grid-wrapper.col-region-collapsed {
      --col3-width: 36px;
  }
  
  .config-grid-wrapper.col-campus-collapsed {
      --col4-width: 36px;
  }
  
  .config-grid-wrapper.col-term-collapsed {
      --col5-width: 36px;
  }
  
  .config-grid-wrapper.col-course-collapsed {
      --col6-width: 36px;
  }
  
  .config-grid {
      display: grid;
      grid-template-columns: 200px var(--col1-width, 1fr) var(--col2-width, 1fr) var(--col3-width, 1fr) var(--col4-width, 1fr) var(--col5-width, 1fr) var(--col6-width, 1fr);
      width: 100%;
      transition: grid-template-columns 0.3s ease;
      /* No overflow - let sticky positioning work */
  }
  
  /* Headers */
  .grid-header {
      background: #1e293b;
      color: white;
      padding: 16px 20px;
      font-weight: 600;
      border-right: 1px solid #334155;
      position: relative;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-height: 80px;
      transition: all 0.3s ease;
  }
  
  .grid-header:last-child {
      border-right: none;
  }
  
  .grid-header.field-label-header {
      background: #0f172a;
      border-right: 2px solid #334155;
  }
  
  .field-label-cell {
      background: #f8fafc;
      border-right: 2px solid #cbd5e1;
      font-weight: 600;
      color: #475569;
      display: flex;
      align-items: center;
      gap: 8px;
  }
  
  .field-label-text {
      flex: 1;
  }
  
  .field-label-selector {
      background: #f8fafc;
      border-right: 2px solid #cbd5e1;
  }
  
  .grid-header:not(.collapsed) {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
  }
  
  .header-content {
      flex: 1;
      transition: opacity 0.3s ease;
  }
  
  .header-level {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      opacity: 0.7;
      margin-bottom: 4px;
  }
  
  .header-title {
      font-size: 16px;
  }
  
  .header-subtitle {
      font-size: 11px;
      opacity: 0.7;
      margin-top: 4px;
  }
  
  /* Collapsed Header Styles */
  .grid-header.collapsed {
      padding: 8px 2px;
      width: 36px !important;
      min-width: 36px !important;
      max-width: 36px !important;
      min-height: 80px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      position: relative;
      background: #1e293b !important;
      color: white;
      transition: all 0.3s ease;
  }
  
  .grid-header.collapsed:hover {
      background: #2e3a4b !important;
  }
  
  .grid-header.collapsed .header-content {
      display: none;
  }
  
  /* Collapse Toggle Button */
  .collapse-toggle {
      background: rgba(255, 255, 255, 0.2);
      border: 1px solid rgba(255, 255, 255, 0.3);
      color: white;
      width: 28px;
      height: 28px;
      border-radius: 4px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s;
      flex-shrink: 0;
      margin-left: 8px;
  }
  
  .collapse-toggle:hover {
      background: rgba(255, 255, 255, 0.3);
      border-color: rgba(255, 255, 255, 0.4);
  }
  
  .collapse-toggle svg {
      width: 16px;
      height: 16px;
      transition: transform 0.3s ease;
      stroke: currentColor;
      fill: none;
  }
  
  .grid-header.collapsed .collapse-toggle {
      width: 18px;
      height: 18px;
      margin: 0;
      background: rgba(255, 255, 255, 0.15);
      padding: 2px;
  }
  
  .grid-header.collapsed .collapse-toggle svg {
      transform: rotate(180deg);
      width: 12px;
      height: 12px;
  }
  
  /* Override Indicator for Collapsed Columns */
  .override-indicator {
      display: none;
      width: 10px;
      height: 10px;
      background: #fbbf24;
      border: 2px solid rgba(251, 191, 36, 0.5);
      border-radius: 50%;
      box-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
  }
  
  .grid-header.collapsed .override-indicator {
      display: block;
      position: absolute;
      top: 10px;
      left: 50%;
      transform: translateX(-50%);
  }
  
  .grid-header.collapsed .override-indicator.no-overrides {
      display: none;
  }
  
  /* Selectors Row */
  .grid-selector {
      padding: 12px 20px;
      background: #f8fafc;
      border-right: 1px solid #e2e8f0;
      border-bottom: 2px solid #cbd5e1;
      transition: all 0.3s ease;
      overflow: hidden;
  }
  
  .grid-selector:last-child {
      border-right: none;
  }
  
  .grid-selector.collapsed {
      padding: 8px 2px;
      width: 36px !important;
      min-width: 36px !important;
      max-width: 36px !important;
      background: #f8fafc;
  }
  
  .grid-selector.collapsed .selector-dropdown {
      display: none;
  }
  
  .selector-dropdown {
      width: 100%;
      padding: 8px 12px;
      border: 1px solid #cbd5e1;
      border-radius: 6px;
      font-size: 14px;
      cursor: pointer;
      background: white;
  }
  
  .selector-dropdown:hover {
      border-color: #94a3b8;
  }
  
  .selector-dropdown:focus {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  /* Group Headers */
  .grid-group-header {
      grid-column: 1 / -1;
      background: #f1f5f9;
      padding: 8px 20px;
      font-size: 11px;
      font-weight: 600;
      color: #64748b;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      border-bottom: 1px solid #e2e8f0;
      border-top: 1px solid #e2e8f0;
      cursor: pointer;
      user-select: none;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: background 0.2s;
  }
  
  .grid-group-header:hover {
      background: #e2e8f0;
  }
  
  .grid-group-header.collapsed {
      background: #e2e8f0;
      border-bottom: 2px solid #cbd5e1;
  }
  
  .chevron {
      width: 16px;
      height: 16px;
      transition: transform 0.3s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
  }
  
  .chevron svg {
      width: 12px;
      height: 12px;
      fill: #64748b;
  }
  
  .grid-group-header.collapsed .chevron {
      transform: rotate(-90deg);
  }
  
  /* Collapsed indicator badge */
  .collapsed-badge {
      margin-left: auto;
      background: #cbd5e1;
      color: #475569;
      padding: 2px 8px;
      border-radius: 10px;
      font-size: 10px;
      font-weight: 500;
  }
  
  .collapsed-badge.has-overrides {
      background: #fbbf24;
      color: #92400e;
  }
  
  /* Section summary when collapsed */
  .section-summary {
      margin-left: 8px;
      display: flex;
      gap: 12px;
      align-items: center;
      font-size: 10px;
      font-weight: normal;
  }
  
  .summary-item {
      display: flex;
      align-items: center;
      gap: 4px;
  }
  
  .summary-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #cbd5e1;
  }
  
  .summary-dot.override {
      background: #fbbf24;
  }
  
  /* Field Cells */
  .grid-field {
      padding: 12px 20px;
      border-right: 1px solid #e2e8f0;
      border-bottom: 1px solid #e2e8f0;
      position: relative;
      transition: all 0.3s ease;
      overflow: hidden;
  }
  
  .grid-field:last-child {
      border-right: none;
  }
  
  .grid-field.collapsed {
      padding: 8px 2px;
      width: 36px !important;
      min-width: 36px !important;
      max-width: 36px !important;
      display: flex;
      align-items: center;
      justify-content: center;
      background: inherit;
  }
  
  .grid-field.collapsed .field-value-wrapper,
  .grid-field.collapsed .array-value-container,
  .grid-field.collapsed .array-controls,
  .grid-field.collapsed .tooltip,
  .grid-field.collapsed .arrow-icon {
      display: none;
  }
  
  /* Collapsed field indicator */
  .collapsed-field-indicator {
      display: none;
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: #cbd5e1;
  }
  
  .grid-field.collapsed .collapsed-field-indicator {
      display: block;
  }
  
  .grid-field.collapsed .collapsed-field-indicator.has-override {
      background: #fbbf24;
      box-shadow: 0 0 3px rgba(251, 191, 36, 0.5);
  }
  
  .grid-field.collapsed .collapsed-field-indicator.inherited-override {
      background: #fb923c;
  }
  
  /* Continue with all existing field styles... */
  .field-value-wrapper {
      display: flex;
      align-items: center;
      gap: 8px;
  }
  
  .field-value {
      padding: 6px 10px;
      background: #f1f5f9;
      border-radius: 4px;
      font-size: 13px;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      transition: all 0.2s;
      user-select: none;
      flex: 1;
  }
  
  .field-value.disabled {
      opacity: 0.5;
      cursor: not-allowed;
      background: #f8fafc;
  }
  
  .field-value.program-default {
      background: #1e293b;
      color: white;
      cursor: not-allowed;
  }
  
  .field-value.inherited {
      background: #e0f2fe;
      color: #0369a1;
  }
  
  .field-value.overridden {
      background: #fef3c7;
      color: #92400e;
      font-weight: 500;
  }
  
  .field-value.inherited-override {
      background: #fed7aa;
      color: #92400e;
  }
  
  .field-value:hover:not(.disabled):not(.program-default) {
      transform: translateY(-1px);
      box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  .inherit-icon {
      font-size: 11px;
      opacity: 0.7;
  }
  
  .arrow-icon {
      position: absolute;
      right: -12px;
      top: 50%;
      transform: translateY(-50%);
      color: #94a3b8;
      font-size: 14px;
      z-index: 1;
      pointer-events: none;
  }
  
  .btn-reset-inline {
      padding: 2px 8px;
      font-size: 11px;
      background: #ef4444;
      color: white;
      border: none;
      border-radius: 3px;
      cursor: pointer;
      transition: background 0.2s;
  }
  
  .btn-reset-inline:hover {
      background: #dc2626;
  }
  
  .tooltip {
      position: absolute;
      bottom: 2px;
      left: 20px;
      font-size: 10px;
      color: #94a3b8;
      white-space: nowrap;
  }
  
  /* Array pills and controls */
  .array-value-container {
      flex: 1;
  }
  
  .array-pills {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-bottom: 8px;
  }
  
  .array-pill {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 4px 8px;
      background: #f1f5f9;
      border: 1px solid #cbd5e1;
      border-radius: 12px;
      font-size: 12px;
      color: #475569;
  }
  
  .array-pill.added {
      background: #dcfce7;
      border-color: #86efac;
      color: #166534;
  }
  
  .array-pill.removed {
      background: #fee2e2;
      border-color: #fca5a5;
      color: #991b1b;
      text-decoration: line-through;
      opacity: 0.7;
  }
  
  .array-pill.override {
      background: #fef3c7;
      border-color: #fde047;
      color: #92400e;
  }
  
  .array-pill.inherited-override {
      background: #fed7aa;
      border-color: #fdba74;
      color: #92400e;
  }
  
  .pill-remove {
      margin-left: 2px;
      padding: 0 2px;
      background: rgba(0, 0, 0, 0.1);
      border-radius: 50%;
      cursor: pointer;
      font-size: 10px;
      line-height: 1;
      transition: background 0.2s;
  }
  
  .pill-remove:hover {
      background: rgba(239, 68, 68, 0.3);
  }
  
  .pill-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      font-size: 10px;
      font-weight: 700;
      margin-left: 4px;
      line-height: 1;
  }
  
  .pill-badge.badge-added {
      background: #22c55e;
      color: white;
  }
  
  .pill-badge.badge-removed {
      background: #ef4444;
      color: white;
  }
  
  .pill-restore {
      margin-left: 4px;
      padding: 0 4px;
      background: rgba(34, 197, 94, 0.2);
      border-radius: 50%;
      cursor: pointer;
      font-size: 12px;
      line-height: 1;
      transition: background 0.2s;
      font-weight: bold;
  }
  
  .pill-restore:hover {
      background: rgba(34, 197, 94, 0.4);
  }
  
  .array-removed-section {
      margin-top: 8px;
      padding: 8px;
      background: #fef2f2;
      border: 1px dashed #fca5a5;
      border-radius: 4px;
  }
  
  .array-removed-label {
      font-size: 10px;
      font-weight: 600;
      color: #991b1b;
      margin-bottom: 4px;
      text-transform: uppercase;
  }
  
  .array-pills-removed {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
  }
  
  .array-controls {
      display: flex;
      gap: 4px;
      margin-top: 4px;
  }
  
  .btn-array {
      padding: 2px 6px;
      font-size: 10px;
      background: #3b82f6;
      color: white;
      border: none;
      border-radius: 3px;
      cursor: pointer;
  }
  
  .btn-array:hover {
      background: #2563eb;
  }
  
  .btn-array.remove {
      background: #ef4444;
  }
  
  .btn-array.remove:hover {
      background: #dc2626;
  }
  
  /* Legend */
  .legend {
      background: white;
      padding: 16px 20px;
      border-radius: 8px;
      margin-top: 20px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  
  .legend h3 {
      font-size: 14px;
      margin-bottom: 12px;
      color: #475569;
  }
  
  .legend-items {
      display: flex;
      flex-wrap: wrap;
      gap: 20px;
  }
  
  .legend-item {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      color: #64748b;
  }
  
  .legend-color {
      width: 20px;
      height: 20px;
      border-radius: 4px;
      border: 1px solid #e2e8f0;
  }
  
  /* Path-Based Grid Styles */
  .path-grid-header {
      background: white;
      padding: 16px 20px;
      border-bottom: 2px solid #e2e8f0;
      display: flex;
      align-items: center;
      gap: 12px;
  }
  
  .path-count {
      font-size: 14px;
      color: #64748b;
      margin-left: auto;
  }
  
  .path-row {
      display: contents;
  }
  
  .path-cell {
      padding: 12px 16px;
      border-right: 1px solid #e2e8f0;
      border-bottom: 1px solid #e2e8f0;
      cursor: pointer;
      transition: background 0.2s;
      background: white;
      font-size: 13px;
  }
  
  .path-cell:hover {
      background: #f8fafc;
  }
  
  .path-cell.has-value {
      font-weight: 500;
      color: #1e293b;
  }
  
  .path-cell.empty {
      color: #cbd5e1;
      font-style: italic;
  }
  
  .path-row.expanded .path-cell {
      background: #eff6ff;
      border-bottom: none;
  }
  
  .path-cell.expanded-at-level {
      background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%) !important;
      color: #1e293b !important;
      font-weight: 600 !important;
      box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1);
  }
  
  .path-cell.in-active-branch {
      background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%) !important;
      color: #334155 !important;
      font-weight: 500 !important;
      border-left: 3px solid #94a3b8 !important;
  }
  
  .path-actions {
      padding: 8px 12px;
      border-bottom: 1px solid #e2e8f0;
      border-right: 2px solid #cbd5e1;
      display: flex;
      gap: 8px;
      align-items: center;
      justify-content: flex-start;
      background: white;
  }
  
  .path-row.expanded .path-actions {
      background: #eff6ff;
      border-bottom: none;
  }
  
  .btn-icon {
      width: 28px;
      height: 28px;
      border: 1px solid #cbd5e1;
      background: white;
      border-radius: 4px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      transition: all 0.2s;
  }
  
  .btn-icon:hover {
      background: #f1f5f9;
      border-color: #94a3b8;
  }
  
  .btn-icon.btn-delete {
      color: #ef4444;
  }
  
  .btn-icon.btn-delete:hover {
      background: #fef2f2;
      border-color: #ef4444;
  }
  
  /* Expanded Editor */
  .expanded-editor {
      background: #f8fafc;
      border: none;
      border-radius: 0;
      padding: 0;
      margin: 0;
  }
  
  .expanded-editor-content {
      max-width: 100%;
      overflow-x: auto; /* Allow horizontal scroll for wide content, doesn't affect sticky headers above */
  }
  
  .editor-group {
      background: white;
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      margin-bottom: 16px;
      overflow: hidden;
  }
  
  .editor-group:last-child {
      margin-bottom: 0;
  }
  
  .editor-group-header {
      background: #f1f5f9;
      padding: 12px 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
      font-weight: 600;
      font-size: 13px;
      color: #475569;
      user-select: none;
      border-bottom: 1px solid #e2e8f0;
  }
  
  .editor-group-header:hover {
      background: #e2e8f0;
  }
  
  .editor-group.collapsed .editor-group-header {
      border-bottom: none;
  }
  
  .editor-group-header .chevron {
      width: 12px;
      font-size: 10px;
      color: #64748b;
  }
  
  .editor-group-header .group-name {
      flex: 1;
  }
  
  .editor-group-header .field-count {
      font-size: 11px;
      color: #94a3b8;
      font-weight: normal;
  }
  
  .editor-group-fields {
      padding: 16px;
  }
  
  .editor-field {
      margin-bottom: 20px;
      padding-bottom: 16px;
      border-bottom: 1px solid #f1f5f9;
  }
  
  .editor-field:last-child {
      margin-bottom: 0;
      padding-bottom: 0;
      border-bottom: none;
  }
  
  .editor-field-label {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;
      font-size: 13px;
      font-weight: 500;
      color: #334155;
  }
  
  .editor-field-value {
      margin-left: 28px;
  }
  
  /* Empty State */
  .empty-state {
      padding: 60px 20px;
      text-align: center;
      color: #94a3b8;
  }
  
  .empty-state h3 {
      margin: 0 0 8px 0;
      font-size: 18px;
      color: #64748b;
  }
  
  .empty-state p {
      margin: 0;
      font-size: 14px;
  }
  
  /* Modal Styles */
  .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: 1000;
  }
  
  .modal-dialog {
      background: white;
      border-radius: 8px;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
      width: 90%;
      max-width: 600px;
      max-height: 90vh;
      overflow: hidden;
      display: flex;
      flex-direction: column;
  }
  
  .modal-header {
      padding: 20px;
      border-bottom: 1px solid #e2e8f0;
      display: flex;
      align-items: center;
      justify-content: space-between;
  }
  
  .modal-header h2 {
      margin: 0;
      font-size: 20px;
      color: #1e293b;
      flex: 1;
  }
  
  .modal-body {
      padding: 20px;
      overflow-y: auto;
      flex: 1;
  }
  
  .modal-footer {
      padding: 16px 20px;
      border-top: 1px solid #e2e8f0;
      display: flex;
      gap: 12px;
      justify-content: flex-end;
  }
  
  .form-group {
      margin-bottom: 20px;
  }
  
  .form-group:last-child {
      margin-bottom: 0;
  }
  
  .form-label {
      display: block;
      margin-bottom: 6px;
      font-size: 13px;
      font-weight: 600;
      color: #475569;
  }
  
  .form-select {
      width: 100%;
      padding: 10px 12px;
      border: 1px solid #cbd5e1;
      border-radius: 6px;
      font-size: 14px;
      background: white;
      cursor: pointer;
  }
  
  .form-select:focus {
      outline: none;
      border-color: #3b82f6;
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  .form-select:disabled {
      background: #f1f5f9;
      color: #94a3b8;
      cursor: not-allowed;
  }
  
  .form-input {
      width: 100%;
      padding: 10px 12px;
      border: 1px solid #cbd5e1;
      border-radius: 6px;
      font-size: 14px;
      background: white;
      transition: all 0.2s;
  }
  
  .form-input:focus {
      outline: none;
      border-color: #64748b;
      box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.1);
  }
  
  .form-input:hover {
      border-color: #94a3b8;
  }
  
  .btn-cancel {
      background: white;
      color: #64748b;
      border: 1px solid #cbd5e1;
  }
  
  .btn-cancel:hover {
      background: #f8fafc;
      border-color: #94a3b8;
  }
  
  
          <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
          <style>
              /* Additional styles for level-based fields */
              .field-not-native {
                  opacity: 0.4;
                  pointer-events: none;
              }
  
              .field-above-natural-level {
                  opacity: 0.6;
              }
  
              .field-preview {
                  font-style: italic;
                  color: #94a3b8;
              }
  
              .level-badge {
                  display: inline-block;
                  font-size: 8px;
                  font-weight: 700;
                  padding: 2px 4px;
                  border-radius: 2px;
                  margin-right: 8px;
                  vertical-align: middle;
                  opacity: 0.8;
                  line-height: 1;
              }
  
              .level-badge.program {
                  background: #dbeafe;
                  color: #1e40af;
              }
  
              .level-badge.state {
                  background: #fef3c7;
                  color: #92400e;
              }
  
              .level-badge.campus {
                  background: #d1fae5;
                  color: #065f46;
              }
  
              /* Dimming for cells with unchanged values */
              .field-cell.dimmed-value {
                  opacity: 0.35;
                  transition: opacity 0.15s ease;
              }
  
              /* Restore opacity on hover for better interaction */
              .field-cell.dimmed-value:hover {
                  opacity: 0.7;
              }
  
              /* Sticky header support for expanded editor */
              .editor-sticky-header,
              .editor-sticky-subheader {
                  position: sticky !important;
                  z-index: 100 !important;
              }
  
              .editor-sticky-header {
                  top: 0 !important;
              }
  
              .editor-sticky-subheader {
                  top: 44px !important;
                  z-index: 99 !important;
              }
  
              /* Filter Controls */
              .filter-controls {
                  background: white;
                  padding: 16px 20px;
                  border-radius: 8px;
                  margin-bottom: 20px;
                  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
                  display: flex;
                  flex-wrap: wrap;
                  align-items: center;
                  gap: 20px;
              }
  
              .filter-section {
                  display: flex;
                  align-items: center;
                  gap: 12px;
              }
  
              .level-pills,
              .field-group-pills {
                  display: flex;
                  flex-wrap: wrap;
              }
  
              .pill-toggle {
                  padding: 6px 14px;
                  font-size: 13px;
                  font-weight: 500;
                  cursor: pointer;
                  transition: all 0.15s ease;
                  user-select: none;
                  border: 2px solid #cbd5e1;
                  background: white;
                  color: #64748b;
                  margin-left: -2px; /* Overlap borders */
              }
  
              .pill-toggle:first-child {
                  border-radius: 6px 0 0 6px;
                  margin-left: 0;
              }
  
              .pill-toggle:last-child {
                  border-radius: 0 6px 6px 0;
              }
  
              .pill-toggle:only-child {
                  border-radius: 6px;
              }
  
              .pill-toggle.active {
                  background: #334155;
                  color: white;
                  border-color: #334155;
                  z-index: 1;
                  position: relative;
              }
  
              .pill-toggle:hover:not(.disabled) {
                  border-color: #334155;
                  z-index: 2;
                  position: relative;
              }
  
              .pill-toggle.active:hover {
                  background: #1e293b;
                  border-color: #1e293b;
              }
  
              .pill-toggle.disabled {
                  opacity: 0.3;
                  cursor: not-allowed;
                  background: #f8fafc;
                  color: #94a3b8;
              }
  
              .pill-toggle.disabled:hover {
                  border-color: #cbd5e1;
              }
  
              /* Primary button styling to match pill colors */
              .btn.btn-primary {
                  background: #334155;
                  border-color: #334155;
                  color: white;
              }
  
              .btn.btn-primary:hover {
                  background: #1e293b;
                  border-color: #1e293b;
              }
  
              /* Side Panel for Entity Management */
              .side-panel-overlay {
                  position: fixed;
                  top: 0;
                  left: 0;
                  right: 0;
                  bottom: 0;
                  background: rgba(0, 0, 0, 0.5);
                  z-index: 1000;
                  display: none;
                  opacity: 0;
                  transition: opacity 0.3s ease;
              }
  
              .side-panel-overlay.open {
                  display: block;
                  opacity: 1;
              }
  
              .side-panel {
                  position: fixed;
                  top: 0;
                  right: 0;
                  width: 800px; /* Default width in pixels for resizing */
                  height: 100vh;
                  background: white;
                  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
                  z-index: 1001;
                  transform: translateX(100%);
                  transition: transform 0.3s ease;
                  display: flex;
                  flex-direction: column;
              }
  
              .side-panel.open {
                  transform: translateX(0);
              }
  
              .side-panel.resizing {
                  transition: none; /* Disable transition during resize */
              }
  
              .side-panel-resize-handle {
                  position: absolute;
                  left: 0;
                  top: 0;
                  width: 8px;
                  height: 100%;
                  cursor: ew-resize;
                  z-index: 1002;
              }
  
              .side-panel-resize-handle::before {
                  content: "";
                  position: absolute;
                  left: 2px;
                  top: 50%;
                  transform: translateY(-50%);
                  width: 4px;
                  height: 40px;
                  background: #cbd5e1;
                  border-radius: 2px;
                  transition: background 0.15s ease;
              }
  
              .side-panel-resize-handle:hover::before,
              .side-panel-resize-handle.dragging::before {
                  background: #334155;
              }
  
              .side-panel-header {
                  padding: 20px 24px;
                  border-bottom: 2px solid #e2e8f0;
                  background: #f8fafc;
                  display: flex;
                  align-items: center;
                  justify-content: space-between;
              }
  
              .side-panel-header h2 {
                  font-size: 18px;
                  font-weight: 600;
                  color: #1e293b;
                  margin: 0;
              }
  
              .side-panel-close {
                  background: none;
                  border: none;
                  font-size: 24px;
                  color: #64748b;
                  cursor: pointer;
                  padding: 4px 8px;
                  line-height: 1;
              }
  
              .side-panel-close:hover {
                  color: #1e293b;
              }
  
              .side-panel-body {
                  flex: 1;
                  overflow-y: auto;
                  padding: 24px;
              }
  
              .side-panel-footer {
                  padding: 16px 24px;
                  border-top: 1px solid #e2e8f0;
                  background: #f8fafc;
                  display: flex;
                  gap: 12px;
                  justify-content: flex-end;
              }
  
              .entity-form-group {
                  margin-bottom: 20px;
              }
  
              .entity-form-label {
                  display: block;
                  font-size: 13px;
                  font-weight: 600;
                  color: #334155;
                  margin-bottom: 8px;
              }
  
              .entity-form-input {
                  width: 100%;
                  padding: 10px 12px;
                  border: 2px solid #cbd5e1;
                  border-radius: 6px;
                  font-size: 14px;
                  transition: border-color 0.15s ease;
              }
  
              .entity-form-input:focus {
                  outline: none;
                  border-color: #334155;
              }
  
              .entity-form-help {
                  font-size: 12px;
                  color: #64748b;
                  margin-top: 4px;
              }
  
              .btn-icon-edit {
                  background: none;
                  border: 1px solid #cbd5e1;
                  padding: 4px 12px;
                  border-radius: 4px;
                  cursor: pointer;
                  font-size: 12px;
                  color: #64748b;
                  transition: all 0.15s ease;
                  display: inline-flex;
                  align-items: center;
                  gap: 4px;
              }
  
              .btn-icon-edit:hover {
                  background: #f1f5f9;
                  border-color: #94a3b8;
                  color: #334155;
              }
  
              .level-add-buttons {
                  display: flex;
                  gap: 8px;
                  margin-left: 12px;
              }
  
              .btn-add-level {
                  padding: 6px 12px;
                  font-size: 12px;
                  background: white;
                  color: #334155;
                  border: 1px solid #cbd5e1;
                  border-radius: 6px;
                  cursor: pointer;
                  transition: all 0.15s ease;
              }
  
              .btn-add-level:hover {
                  background: #f8fafc;
                  border-color: #94a3b8;
              }
  
              /* Mega text gradient animation */
              .mega-text {
                  font-weight: 900;
                  background: linear-gradient(
                      90deg,
                      #ff0080,
                      #ff8c00,
                      #40e0d0,
                      #9370db,
                      #ff1493,
                      #ff0080
                  );
                  background-size: 300% 100%;
                  -webkit-background-clip: text;
                  background-clip: text;
                  -webkit-text-fill-color: transparent;
                  animation: gradientCycle 4s ease infinite;
              }
  
              @keyframes gradientCycle {
                  0% {
                      background-position: 0% 50%;
                  }
                  50% {
                      background-position: 100% 50%;
                  }
                  100% {
                      background-position: 0% 50%;
                  }
              }
  
              /* Mode Toggle Buttons */
              .mode-toggle {
                  padding: 12px 24px;
                  font-size: 14px;
                  font-weight: 600;
                  background: white;
                  color: #334155;
                  border: none;
                  cursor: pointer;
                  transition: all 0.2s ease;
                  border-right: 1px solid #cbd5e1;
              }
  
              .mode-toggle:last-child {
                  border-right: none;
              }
  
              .mode-toggle.active {
                  background: #334155;
                  color: white;
              }
  
              .mode-toggle:hover:not(.active) {
                  background: #f8fafc;
              }
  
              /* Analytics View Styles */
              .analytics-container {
                  max-width: 100%;
                  margin: 0 auto;
                  padding: 0 20px;
              }
  
              .analytics-content {
                  display: grid;
                  grid-template-columns: 260px 1fr;
                  gap: 20px;
                  padding-top: 20px;
                  align-items: start;
              }
  
              .analytics-left-column {
                  position: sticky;
                  top: 20px;
              }
  
              .analytics-right-column {
                  min-width: 0;
                  width: 100%;
              }
  
              /* Override config-grid styles when in analytics mode */
              .config-grid.analytics-mode {
                  display: block !important;
                  grid-template-columns: none !important;
              }
  
              .courses-grid {
                  display: grid;
                  grid-template-columns: repeat(auto-fit, minmax(280px, 350px));
                  gap: 12px;
                  width: 100%;
              }
  
              .region-section {
                  margin-bottom: 40px;
              }
  
              .region-header {
                  font-size: 22px;
                  font-weight: 700;
                  color: #1e293b;
                  margin: 0 0 24px 0;
                  padding-bottom: 12px;
                  border-bottom: 3px solid #334155;
              }
  
              .program-section {
                  margin-bottom: 28px;
              }
  
              .program-header {
                  display: flex;
                  align-items: center;
                  justify-content: space-between;
                  margin-bottom: 12px;
                  padding: 8px 0;
              }
  
              .program-title {
                  font-size: 16px;
                  font-weight: 600;
                  color: #475569;
                  margin: 0;
              }
  
              .program-stats {
                  font-size: 12px;
                  color: #64748b;
                  font-weight: 500;
              }
  
              .analytics-header {
                  background: white;
                  padding: 16px;
                  border-radius: 8px;
                  margin-bottom: 20px;
                  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
              }
  
              .analytics-filters {
                  display: flex;
                  gap: 12px;
                  align-items: center;
                  flex-wrap: wrap;
              }
  
              .analytics-filter-group {
                  display: flex;
                  flex-direction: column;
                  gap: 6px;
              }
  
              .analytics-filter-label {
                  font-size: 10px;
                  font-weight: 600;
                  color: #64748b;
                  text-transform: uppercase;
              }
  
              .course-card {
                  background: white;
                  border-radius: 8px;
                  padding: 16px;
                  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
                  transition: all 0.2s ease;
                  display: flex;
                  flex-direction: column;
                  height: 100%;
              }
  
              .course-card:hover {
                  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
                  transform: translateY(-2px);
              }
  
              .course-card-header {
                  display: flex;
                  justify-content: space-between;
                  align-items: flex-start;
                  gap: 12px;
                  margin-bottom: 12px;
                  padding-bottom: 12px;
                  border-bottom: 2px solid #e2e8f0;
              }
  
              .course-title {
                  font-size: 15px;
                  font-weight: 700;
                  color: #1e293b;
                  margin: 0 0 6px 0;
                  line-height: 1.3;
              }
  
              .course-meta {
                  font-size: 11px;
                  color: #64748b;
                  display: flex;
                  flex-direction: column;
                  gap: 4px;
              }
  
              .course-capacity {
                  margin: 12px 0;
              }
  
              .capacity-label {
                  font-size: 12px;
                  font-weight: 600;
                  color: #334155;
                  margin-bottom: 8px;
                  display: flex;
                  justify-content: space-between;
              }
  
              .capacity-bar {
                  height: 24px;
                  background: #e2e8f0;
                  border-radius: 12px;
                  overflow: hidden;
                  position: relative;
              }
  
              .capacity-fill {
                  height: 100%;
                  transition: width 0.3s ease;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  font-size: 11px;
                  font-weight: 700;
                  color: white;
              }
  
              .capacity-fill.high {
                  background: linear-gradient(90deg, #10b981, #059669);
              }
  
              .capacity-fill.medium {
                  background: linear-gradient(90deg, #f59e0b, #d97706);
              }
  
              .capacity-fill.low {
                  background: linear-gradient(90deg, #ef4444, #dc2626);
              }
  
              .course-actions {
                  display: grid;
                  grid-template-columns: 1fr 1fr;
                  gap: 6px;
                  margin-top: auto;
                  padding-top: 12px;
              }
  
              .action-btn {
                  padding: 8px 12px;
                  font-size: 11px;
                  font-weight: 600;
                  border: 1px solid #cbd5e1;
                  border-radius: 6px;
                  background: white;
                  color: #334155;
                  cursor: pointer;
                  transition: all 0.15s ease;
                  text-align: center;
                  white-space: nowrap;
              }
  
              .action-btn:hover {
                  background: #f8fafc;
                  border-color: #94a3b8;
              }
  
              .action-btn.primary {
                  background: #334155;
                  color: white;
                  border-color: #334155;
              }
  
              .action-btn.primary:hover {
                  background: #1e293b;
                  border-color: #1e293b;
              }
  
              .analytics-stats {
                  display: flex;
                  flex-direction: column;
                  gap: 12px;
                  margin-bottom: 24px;
              }
  
              .stat-card {
                  background: white;
                  padding: 12px 14px;
                  border-radius: 8px;
                  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
              }
  
              .stat-value {
                  font-size: 24px;
                  font-weight: 700;
                  color: #1e293b;
                  margin-bottom: 2px;
                  line-height: 1;
              }
  
              .stat-label {
                  font-size: 10px;
                  color: #64748b;
                  text-transform: uppercase;
                  font-weight: 600;
                  line-height: 1.3;
              }
          </style>
}

/* Disabled button state */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.btn:disabled:hover {
    background-color: inherit;
}
